Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have Checkbox as ColumnHeader of dataGridView

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 if i select all the Checkboxex in the column should get selected. How can i do this.? I referred the Code Project link

But if i use that, if i click the FirstCell (not the Header) all the below cells are getting selected. But i want a CheckBox in the Column header. How can i do this.?

like image 945
SyncMaster Avatar asked May 15 '09 13:05

SyncMaster


People also ask

How to Add CheckBox in DataGridView Column Header in VB net?

'Find the Location of Header Cell. 'Place the Header CheckBox in the Location of the Header Cell. 'Assign Click event to the Header CheckBox. 'Add a CheckBox Column to the DataGridView at the first position.


1 Answers

If you choose @Ehsan solution you must know that if the checkbox cell is selected it won't update the checkbox UI. You need to call RefreshEdit() afterwards.

It only happens when the control is child-control of the datagridview. For some reason when it is a child-control the selected cell checkboxes are not able to refresh the UI by their own.

like image 138
Ana Avatar answered Sep 28 '22 22:09

Ana