更新时间:2022-05-01 02:52:55
您好,我们可以通过以下方式检查是否选中了复选框
Hi, here is how you can check if the checkbox is selected or not
foreach (DataGridViewRow row in dataGridView.Rows)
{
//we check if the cell number 5(the checkbox) is checked or not
if (Convert.ToBoolean(row.Cells[4].Value) == true)
{
//here you can do your save in database operation
}
}
我个人讨厌直接使用datagrid数据。
我总是将我的数据保存在列表中,然后将数据放入数据网格中。
操作将更容易,并且产生错误的可能性很小。
如果您的类对象中没有已检查的属性,那么您可以设法使用inheritence添加neww属性(创建一个继承自您的新类)主要课程并为检查项目添加一个booleen道具)
希望它有所帮助
I personllay hate working with datagrid data directly.
I always save my data in a list and then put that data in the datagrid.
Operation will be much easier, and the possibilites to make error is minor.
If you don't have a checked properties in your class object, then you can manage to add a neww properties using inheritence(create a new class that inherit from your main class and add a booleen prop for checked items)
Hope it helps
嗨...
如何选择选中复选框时,将显示gridm的数值 [ ^ ]
谢谢你。
Hi...
how to select values frm gridview when checkbox is checked[^]
Thank u.