I have a DataGridView with several columns and several rows of data. One of the columns is a DataGridViewCheckBoxColumn and (based on the other data in the row) I would like the option to “hide” the checkbox in some rows. I know how to make it read only but I would prefer it to not show up at all or at least display differently (grayed out) than the other checkboxes. Is this possible?
I have a DataGridView with several columns and several rows of data. One of
Share
Some workaround: make it read-only and change back color to gray.
For one specific cell:
Or, better but more “complicated” solution:
suppose you have 2 columns: first with number, second with checkbox, that should not be visible when number > 2. You can handle
CellPaintingevent, paint only borders (and eg. background) and break painting of rest. Add eventCellPaintingfor DataGridView (optionally test for DBNull value to avoid exception when adding new data in empty row):It should work, however if you change value manually in first column, where you check condition, you must refresh the second cell, so add another event like
CellValueChanged: