CurrentCellChanged 事件private void CallCurrentCellChanged()
{
   myDataGrid.CurrentCellChanged += new EventHandler(Grid_CurCellChange);
}// Raise the event when focus on DataGrid cell changes.
protected void Grid_CurCellChange(object sender, EventArgs e)
{
   // String variable used to show message.
   string myString = "CurrentCellChanged event raised, cell focus is at ";
   // Get the co-ordinates of the focussed cell.
   string myPoint  = myDataGrid.CurrentCell.ColumnNumber + "," +
                  myDataGrid.CurrentCell.RowNumber;
   // Create the alert message.
   myString = myString + "(" + myPoint + ")";
   // Show Co-ordinates when CurrentCellChanged event is raised.
   MessageBox.Show(myString, "Current cell co-ordinates");
}

解决方案 »

  1.   

    不知道你是在开发何种程序,winform还是web
      

  2.   

    WINFORM,我的意思是想实现:双击dataGrid中的一条记录,会弹出一个新的Form,该Form上的几个控件(如label)绑定所双击的那条记录的几个字段,在C++Builder中是用FieldByName()来实现的,C#中不知该如何做?GZing
      

  3.   

    label1.Text=Field[0].ToString;
    label2.Text=Field[1].ToString;
      

  4.   

    用DataGrid.HitTestInfo来做。查一下这方面的例子。
    以前CSDN上好象有过。
      

  5.   

    DataGrid.HitTestInfo 可以取得你点击在DataGrid的何处,比如是 Cell里的话,还可以取得点击的行和列,这样就可以知道你点的是哪一个单元格了。—————————————————————————————————
    email: [email protected]