Link to home
Start Free TrialLog in
Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America

asked on

CheckBox Column in DataGridView defaults to ReadOnly being True?

I have a Column in my DGV that is defined as a DataGridViewCheckBoxCell. My query that is bound to the DGV looks like this:

SELECT      0 AS Selected, EquipID, EquipName, Model, SN, Accredited, Description FROM CalEquip ORDER BY TypeID, EquipName

The first column acts as my CheckBox Column in my DGV. My problem is that even when I manually set the ReadOnly property to False, I run the app and when I try to check/uncheck the column, it won't allow me to. When I go back into the designer and look at that Column, it shows the ReadOnly property is True. What am I doing wrong?

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada 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 BlakeMcKenna

ASKER

Thanks James...that worked!
I am allowed to check/uncheck that field now but now the problem is that it always loads as checked. I need to load in an unchecked mode.
If you did it through an extra field instead of doing it with the extra column added through code, it gets updated along with the other columns.

You can get rid of that 4 different ways:

- Remove the checks through code before doing an update.
- When finished working with the data, run a SQL command that resets the value to False for all rows where it is True in the database.
- Or run the same command before filling up the grid.
- Do not use the field trick, and use my second recommendation instead.
Thanks James, I'll give it a try!