本文介绍了获取Winforms中datagridview的选定复选框的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的Windows应用程序中有一个datagridView,其中已在0位置插入了一个复选框列.现在,我想从此网格中获取所选复选框的ID,以便在删除按钮上单击,我可以为所选行引发isDelete标志并将其隐藏.
我正在寻找获取ID的解决方案,但在那方面没有成功....请帮助我获取所选行的ID.
Hi all,
I have one datagridView in my windows application in which i have inserted a checkbox column at 0 position. now i want to get the id of selected checkboxes from this grid so that at my delete button click i can raise isDelete flag for selected rows and hide them.
i am searching for the solution to get the ID but i am not getting success in that .... please help me to get the ID of selected rows.
推荐答案
private void btnDelete_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow Row in DataGridView1.Rows)
{
if (Row.Cells[0].Value != null)
{
if ((bool)(Row.Cells[0].Value) == true)
{
int tradeID = Convert.ToInt32(DataGridView1.Rows[Row.Index].Cells["ID"].Value.ToString());
// Write Update Query for the ID received here
}
}
}
loadDataGrid();
}
这篇关于获取Winforms中datagridview的选定复选框的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!