How to have Checkbox as ColumnHeader of dataGridView

前端 未结 6 2005
鱼传尺愫
鱼传尺愫 2020-12-24 04:00

I\'m developing a window application in C# VS2005. I have a dataGridView in which the first column has Checkboxes. Now i want the Column header also to be a CheckBox which i

6条回答
  •  悲&欢浪女
    2020-12-24 04:24

    So - to address the top-most checkbox not showing as checked (even though it is), I ended up editing your event as follows:

    private void checkboxHeader_CheckedChanged(object sender, EventArgs e) { //CheckBox headerBox = ((CheckBox)dtgv1.Controls.Find("checkboxHeader", true)[0]);

            var headerBox = (CheckBox)sender;
            var b = headerBox.Checked;
            var c = int.Parse(headerBox.Name.Replace("checkboxHeader", ""));
            for (int i = 0; i < dgvSources_fuzzyID.RowCount; i++)
            {
                dgvSources_fuzzyID.Rows[i].Cells[0].Value = headerBox.Checked;
                ***dgvSources_fuzzyID.RefreshEdit();***
            }
        }
    

    That is what finally fixed it for me...

提交回复
热议问题