怎么得到DataGrid中选中的一行的某个字段值? 谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 x=((DataTable)datagrid1.DataSource)[datagrid.CurrentRowIndex]["字段名"] 同学,你装个MSDN2003不是那么难吧?查一下就知道了 你比如你在编辑的时候选种了一行 就是这样 XX = e.Item.Cells(0).Text单元格: XX=DATAGRID.Items(i).Cells(1).Text.Trim() x=((DataTable)datagrid1.DataSource).DefaultView.Rows[datagrid.CurrentRowIndex]["字段名"] zhxudong(zhxudong)大哥,拜托你测试一下。 string id=e.Item.Cells[1].Text;//得到当前行的某个值正解 string s1=this.dataSet11.Tables["tablename"].Rows[this.dataGrid1.CurrentRowIndex]["columnname"].ToString(); string str=DataGrid1.Items[e.Item.ItemIndex].Cells[要取的column].Text();string str=e.Item.Cells[要取的column].Text();int i=DataGrid1.CurrentPageIndex*DataGrid1.PageSize+e.Item.ItemIndex;string str=DataSource.Roew[i]["要取的column"].Tostring(); //DataSource:记录DataGrid数据源的DataTable 楼上的朋友说的不对,当对DATAGRID排序时选择的值就错了.必须用BindMangerViewBase来处理.如:System.Windows.Forms .BindingManagerBase bm=this.dataGrid1 .BindingContext [this.dataGrid1 .DataSource ,this.dataGrid1 .DataMember ]; DataRow dr=((DataRowView)bm.Current ).Row; ClientName=dr["姓名"].ToString (); c#调用非托管c++代码 怎样获取远程目录下的所有文件名并下回本地指定目录? VB 6.0 和 VB 2005/2008 哪个写外挂好呀。 Windows service 模板 c#遍历我的电脑的问题! 使用 foreach 访问集合类问题 请教c# windows 应用程序 界面制作的问题: 一个toolbar和statusbar结合的问题 C#中能调用到C++的模板函数吗? 在子窗口内如何访问父窗口类的私有方法啊?(在线等!!!) ????如何获得表名?????? 捡分!简单问题
选种了一行 就是这样 XX = e.Item.Cells(0).Text
单元格: XX=DATAGRID.Items(i).Cells(1).Text.Trim()
正解
string str=e.Item.Cells[要取的column].Text();int i=DataGrid1.CurrentPageIndex*DataGrid1.PageSize+e.Item.ItemIndex;
string str=DataSource.Roew[i]["要取的column"].Tostring(); //DataSource:记录DataGrid数据源的DataTable
如:
System.Windows.Forms .BindingManagerBase bm=this.dataGrid1 .BindingContext [this.dataGrid1 .DataSource ,this.dataGrid1 .DataMember ];
DataRow dr=((DataRowView)bm.Current ).Row;
ClientName=dr["姓名"].ToString ();