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?

Visual Basic.NET

Avatar of undefined
Last Comment

8/22/2022 - Mon
Jacques Bourgeois (James Burger)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

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.
Jacques Bourgeois (James Burger)

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

Thanks James, I'll give it a try!