Link to home
Start Free TrialLog in
Avatar of dominicwong
dominicwong

asked on

How to grey out (or disable) column of checkboxes in datagridview (C#, Winform)

Hi experts
I have a datagridview that contains a column of checkboxes.

I would like to grey out (or disable) the column programmatically. I tried ".ReadOnly" but that only disallowed user from using it. I want to make it visually show that it is not in use.

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of masterpass
masterpass
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dominicwong
dominicwong

ASKER

Smart! Thanks masterpass.

I did this as I am interested in the whole column.
    dgv.Columns[1].ReadOnly = true;
    dgv.Columns[1].DefaultCellStyle.BackColor = Color.LightGray;

It doesn't grey out the checkbox (that would be ideal), but it serves the purpose.

Do you know, by any chance, any easy mean to grey out the checkboxes too?
unfortunately there is no easy way around the look of the checkbox. You will have to repaint the checkbox using code!

this will help u : http://www.codeproject.com/Articles/31829/Disabled-Checkbox-Column-in-the-DataGridView

hope this helps!
I think I provided the answer.
Sorry masterpass. It must be an accident. I thought I'd accepted your solution with the 500 points.

Moderator, kindly please fix this mistake and give the 500 points to masterpass for his help and excellent answer.
Closing this again. And thanks again to masterpass.