dgMain 是一个dataGrid
int l=this.dgMain.CurrentRowIndex;
if (l<0) return;
row=dt.Rows[l];
id = row["id"].ToString();
row["你要的字段"].ToString()就可以了
int l=this.dgMain.CurrentRowIndex;
if (l<0) return;
row=dt.Rows[l];
id = row["id"].ToString();
row["你要的字段"].ToString()就可以了
private int l;
private string id;l = this.dgMain.CurrenRowIndex;
row = this.dgMain.DataSource.row[l];
id = row["string"].ToString();
private int l;
private string id;l = this.dgMain.CurrenRowIndex;
row = this.dgMain.DataSource.row[l];
id = row["string"].ToString();
如下是得到前三个字段的内容。
string strYgbh = DataGrid1[DataGrid1.CurrentRowIndex,0].ToString();
string strDept = DataGrid[DataGrid1.CurrentRowIndex,1].ToString();
string strUidXm = DataGrid1[DataGrid.CurrentRowIndex,2].ToString();
dt是什么?