在DataGridview中点击添加一个CheckBoxList列

C#DataGridView设置CheckBoxList

添加完成后添加cellClick事件:

 if (e.RowIndex > -1 && dataGridView_Pipetype.SelectedCells.Count > 0)
                {
                    //点击button按钮事件“IsSelect”是我创建复选框列时候的列名
                    if (e.ColumnIndex != -1 && DataGridView_Config.Columns[e.ColumnIndex].Name == "IsSelect" && e.RowIndex >= 0)
                    {
                        bool Ischecked = Convert.ToBoolean(DataGridView_Config.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);

                        DataGridView_Config.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = !Ischecked;
                    }

通过这个事件就可以进行更改复选框的状态。

相关文章:

  • 2022-12-23
  • 2021-07-16
  • 2021-10-19
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2021-05-23
相关资源
相似解决方案