DataGridView and CheckBox
本文关键字:CheckBox and DataGridView | 更新日期: 2023-09-27 18:35:49
>我使用数据集将数据库连接到DataGridView,并设置了:
DataGridView.autogenerate=false
然后我使用 gui 属性逐列添加,然后将其中一列作为复选框。
首先,我想将复选框的值设置为 true 或 false,然后检查该值是否为 true,如果为 true,那么我想获取另一列的值,但在同一行中,然后隐藏当前行。
首先,您需要检查该单元格是否被选中。
if (DataGridViewRow.Cells[CellNumber].Value != null)
{
if ((Boolean)DataGridViewRow.Cells[CellNumber].Value == true)
{
//Get other cell value
}
}
完成此操作后,您可以隐藏该行。
DataGridViewRow.Visible = false;