dgMain 是一个dataGrid
int l=this.dgMain.CurrentRowIndex;
if (l<0) return;
row=dt.Rows[l];
id = row["id"].ToString();
row["你要的字段"].ToString()就可以了

解决方案 »

  1.   

    上面代码中的dt是dataGrid.DataSourceprivate DataGrid dgMain;
    private int l;
    private string id;l = this.dgMain.CurrenRowIndex;
    row = this.dgMain.DataSource.row[l];
    id = row["string"].ToString();
      

  2.   

    上面代码中的dt是dataGrid.DataSourceprivate DataGrid dgMain;
    private int l;
    private string id;l = this.dgMain.CurrenRowIndex;
    row = this.dgMain.DataSource.row[l];
    id = row["string"].ToString();
      

  3.   

    看你想得到当前选中记录的某个字段内容,前提是你DataGrid1已和Table绑定了。
    如下是得到前三个字段的内容。
    string strYgbh = DataGrid1[DataGrid1.CurrentRowIndex,0].ToString();
    string strDept = DataGrid[DataGrid1.CurrentRowIndex,1].ToString();
    string strUidXm = DataGrid1[DataGrid.CurrentRowIndex,2].ToString();
      

  4.   

    有点不明白,row是DataRow类型的吗?
    dt是什么?