关于datagridview选中行 int i = this.father._dgv.SelectedRows[0].Index;我这样可以选中行没?怎么还是弹出错误:索引超出范围。必须为非负值并小于集合大小。参数名: index 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有啊 我是想从选中的行里面数据赋值给显示出来:int i = this.father._dgv.SelectedRows[0].Index;this.tb1.Text = this.father._dgv.SelectedRows[i].Cells[0].Value.ToString();this.tb2.Text = this.father._dgv.SelectedRows[i].Cells[1].Value.ToString();this.tb3.Text = this.father._dgv.SelectedRows[i].Cells[2].Value.ToString(); DataRowView drv = dataGridView.SelectedRows[0].DataBoundItem as DataRowView;DataGridView1.CurrentRow.Index 获得包含当前单元格的行的索引 是否选择了行 用这个:DataGridView1.CurrentRow.Index 我选中那行有 3 个单元格我是想把选中行的每个单元格的值 分别 赋给 :this.tb1.Text, this.tb2.Text ,this.tb3.Text 就在这时出错了~~ this.tb1.Text = this.father._dgv.SelectedRows[0].Cells[0].Value.ToString(); 直接这样写不行吗? 嗯 这样可以 但是我想用 int i = this.father._dgv.SelectedRows[0].Index; 这句来获取行号~~然后再赋值 就不行了~~~ string ii = this.father._dgv.Row[i].Cells[i].Text 大哥:这样做太麻烦了,给你一个好的建议,在GridView前面加上Checkboxlist去做。 还有个方法就是把datagridview里的数据放到datatable里面去datatable dt = new datatable();table.Columns.Add(...)DataRow row = table.NewRow();row[0]=.. 这个问题!其实都不需要用到索引的this.tb1.Text = this.father._dgv.SelectedRows[0].Cells[0].Value.ToString(); this.tb2.Text = this.father._dgv.SelectedRows[0].Cells[1].Value.ToString(); this.tb3.Text = this.father._dgv.SelectedRows[0].Cells[2].Value.ToString();就可以实现了!不需要用到a SelectedRows[0]这个地方用错是了应该是this.tb1.Text = this.father._dgv.SelectedRows[i].Cells[0].Value.ToString(); 写错了,是这样的this.tb1.Text = this.father._dgv.Rows[i].Cells[0].Value.ToString(); int index = ((DataGrid)sender).CurrentCell.RowNumber; ((DataGrid)sender).Select(index); 如何在定时器中实现一个sleep功能 SqlServer2008无法用SQL身份验证登录(求助) XtraCharts.ChartControl画折线图时,如何自定义标签label的显示 关于操作自定义配置文件的类问题 多线程访问串口问题(急!) 大虾们,江湖救急啊...各位帮帮忙 ----------组件开发的小问题(与外界怎么交互)------- 关于在Rose和.net,希望大家给给看法 windows service 内存上涨问题 如何用GDI+实现透明的PNG格式图片文件的制作输出? 在线等待 泛型反射无法获取及设置属性 结构体如何循环赋值?
this.tb1.Text = this.father._dgv.SelectedRows[i].Cells[0].Value.ToString();
this.tb2.Text = this.father._dgv.SelectedRows[i].Cells[1].Value.ToString();
this.tb3.Text = this.father._dgv.SelectedRows[i].Cells[2].Value.ToString();
DataGridView1.CurrentRow.Index 获得包含当前单元格的行的索引
是否选择了行
直接这样写不行吗?
嗯 这样可以 但是我想用 int i = this.father._dgv.SelectedRows[0].Index; 这句来获取行号~~然后再赋值 就不行了~~~
datatable dt = new datatable();
table.Columns.Add(...)
DataRow row = table.NewRow();
row[0]=..
this.tb1.Text = this.father._dgv.SelectedRows[0].Cells[0].Value.ToString();
this.tb2.Text = this.father._dgv.SelectedRows[0].Cells[1].Value.ToString();
this.tb3.Text = this.father._dgv.SelectedRows[0].Cells[2].Value.ToString();
就可以实现了!不需要用到a
this.tb1.Text = this.father._dgv.SelectedRows[i].Cells[0].Value.ToString();
this.tb1.Text = this.father._dgv.Rows[i].Cells[0].Value.ToString();