silverght 中 DataGrid 在窗体启动加载的时候,默认选择第一行,
silverght 中 DataGrid 在窗体启动加载的时候,默认选择第一行
并且获取该行的对象
将该对象,赋值给其他的控件
private void BindLoad() { //加载下拉列表框,数据 DBServiceClient proxy = new DBServiceClient("BasicHttpBinding_IProductService"); proxy.GetAllStudentAsync(); proxy.GetAllStudentCompleted += new EventHandler<GetAllStudentCompletedEventArgs>(proxy_GetAllStudentCompleted); ////绑定 datagrid 数据 proxy.GetAllUserAsync(); proxy.GetAllUserCompleted += new EventHandler<GetAllUserCompletedEventArgs>(proxy_GetAllUserCompleted); this.dgvShow.SelectedIndex = 0; //DataGridRow r = ; SUser us = new SUser(); us = (SUser)(this.dgvShow.SelectedItem); if (us != null) { //SLChildWindow sl = new SLChildWindow(user.Id); //sl.Show(); this.txtSN.Text = Convert.ToString(us.Name); this.txtSx.Text = Convert.ToString(us.Sex); this.txtPh.Text = Convert.ToString(us.Phone); this.txtAd.Text = Convert.ToString(us.Adress); this.txtAg.Text = Convert.ToString(us.Age); this.txtCl.Text = Convert.ToString(us.StudentID); } }
public class SUser { public string Name { get; set; } public string Sex { get; set; } public string Phone { get; set; } public string Address { get; set; } public string Age { get; set; } public string StudentID { get; set; } }