不错!
int rowid=dataGrid1.HitTest(e.X,e.Y).Row;

解决方案 »

  1.   

    这样,以排序就麻烦了,不如这样
    ((datarowview)this.bindingcontext[datagrid1.datasource,datagrid1,datamember].current).delete()
      

  2.   

    curRow = this.dataSet11.Tables["foodsort"].Rows[this.dataGrid1.CurrentCell.RowNumber];//取得当前行
      

  3.   

    RowNo=DataGrid.HitTest(e.X,e.Y).Row;
    具体可以查看msdn
      

  4.   

    datagrid.CurrentRowIndex就是当前焦点所在行了
      

  5.   

    哥们看 帮助
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemwindowsformsdatagridclasstopic.htm其中这句话:“注意   由于可以自定义列数(通过添加或删除 GridColumnStylesCollection 的成员),而且可以按列对行进行排序,因此不能确保 RowNumber 和 ColumnNumber 属性值与 DataTable 中的 DataRow 和 DataColumn 索引相符。因此,请避免在 Validating 事件中使用这些属性来验证数据。”
    解决方法:http://community.csdn.net/Expert/topic/3321/3321426.xml?temp=.2235681
      

  6.   

    DataRowView drv =(Datarowview)this.BindingContext[datagrid1.DataSource].current)
    if(drv.row != null) drv.Row.Delete();