DataGridView点击事件
//获取选中行的索引
int numHang = this.dGFactoryList.CurrentRow.Index;
//获取选中行 中 列的索引
int numLie = this.dGFactoryList.CurrentCell.ColumnIndex;
//获取选中列的Name
string LieName = this.dGFactoryList.Columns[numLie].Name;
//获得指定行列修改过后值
string strInfo = this.dGFactoryList.Rows[numHang].Cells[numLie].Value.ToString();
//获得修改行的主键
string RE_Code = this.dGFactoryList.Rows[numHang].Cells["RE_Code"].Value.ToString();
//判断DataGridView 中的DataGridViewCheckBoxColumn是否选中
for (int i = 0; i < dGFactoryLis.Rows.Count - 1; i++) //循环datagridview每行
{
//IsDell name属性的命名
if ((bool)dGFactoryList.Rows[i].Cells["IsDell"].EditedFormattedValue == true)
{
selectRows = selectRows + "[" + i.ToString() + "]";
}
本文介绍了如何使用C#操作DataGridView控件,包括获取选中行的索引、列索引及值等,同时展示了如何判断DataGridView中的复选框列状态。
6873

被折叠的 条评论
为什么被折叠?



