0

我打开表单,但无法检查第一个单元格的数据视图。我的代码在下面,我想默认检查所有复选框单元格。这个代码在 form_load 中。谁有好主意。我测试了很多方法。

DataGridView1.Refresh(); int count = Convert.ToInt32(DataGridView1.RowCount.ToString());

        for (int i = 0; i < count; i++)
        {

            DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)DataGridView1.Rows[i].Cells[0];
            checkCell.Value = true;
            Boolean flag = Convert.ToBoolean(checkCell.Value);
            if (flag == false)     
            {
                checkCell.Value = true;
            }
            else
                continue;
        }

在此处输入图像描述

4

0 回答 0