这是我的代码
int IdNo;
DataGridViewRow dr = dataGridView1.CurrentRow;
IdNo= dr.Cells["ID"].Value;
问题是每次取的值却是下一行的记录而不是本行的记录,请问会是什么问题呢
int IdNo;
DataGridViewRow dr = dataGridView1.CurrentRow;
IdNo= dr.Cells["ID"].Value;
问题是每次取的值却是下一行的记录而不是本行的记录,请问会是什么问题呢
int IdNo = Convert.ToInt32(dataGridView1.CurrentRow[0].Cells["ID"].Value);
clandyLee兄弟,有出现以下错误
错误 3 无法将带 [] 的索引应用于“System.Windows.Forms.DataGridViewRow”类
比如,是这么绑定的。BindingSource bs = new BindingSource();
bs.DataSource = dataSet1;
bs.DataMember = "Table";dataGridView1.DataSource = bs;....
DataRowView drv = (DataRowView)bs.Current;
int IdNo = int.Parse(drv["ID"].ToString());
int IdNo = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["ID"].Value);刚记错了~不好意思!~
dataGridView1.SelectedRows.Count为当前选中行数.
删除多行使用for循环即可!