可以做到双击某行,弹出对话框,对某条记录进行修改
完成后,刷新DataGrid

解决方案 »

  1.   

    DataSet.Tables[0].Rows[DataGrid.CurrentRow]可以得到当前行
      

  2.   

    LYH1977() :你的方法有点用,只是如果我用某个字段排序了之后,就要出错了。
      

  3.   

    DataGrid的数据源用DataView 比较好,例如客户要求你在DataGrid中单击某列排序,如果用DataTable的话你将丢掉DataGrid与DataTable的参考的索引定位不到你要的那条记录就惨了。
      

  4.   

    dataGrid1.CurrentRowIndex可以得到当前的行号。
    dataGrid1[dataGrid1.CurrentRowIndex,i]可以得到某一个cell中的值,其中i为列号。
    关于DataGrid的用法见:
    http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
      

  5.   

    In an unsorted DataGrid bound to a DataTable, you can get a reference to a row in the DataTable through the DataGrid.CurrentRowIndex.  
         DataTable dt = (DataTable) this.dataGrid1.DataSource; 
     
         DataRow dr = dt.Rows[this.dataGrid1.CurrentRowIndex); 
     But if the grid has been sorted, you can no longer get at the current row in the table through the grid's CurrentRowIndex. But for both unsorted and sorted grids, you can get at the current row through the BindingContext and the Current property of the BindingManagerBase. 
     
    [C#] 
     
         BindingManagerBase bm = this.dataGrid1.BindingContextr[this.dataGrid1.DataSource, this.dataGrid1.DataMember]; 
     
         DataRow dr = ((DataRowView)bm.Current).Row; 
     双击问题见:
    http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q869q