We help IT Professionals succeed at work.
Get Started

C# CheckState of a Checkbox

huerita37
huerita37 asked
on
329 Views
Last Modified: 2016-10-17
I dynamically add a datagridview to my form.  When a user types in a number and hits 'Enter' the datagridview is created and populated.  I also add a checkbox in the column header so the user can toggle between checking and unchecking all of the boxes.  My problem comes when the user clicks on the 'Clear' button.  I would like the 'Clear' button to clear the whole grid and 'Uncheck' the column header checkbox if it is checked.  Here is my problem:

  1. I 'Check' the column Header checkbox
  2. The very first time I click on the 'Clear' button the column header checkbox is unchecked
  3. I 'Check the column Header checkbox a 2nd time
  4. I click on the 'Clear' button a 2nd time and everything BUT the column header checkbox is cleared

When I step through my code it is already showing that the column header checkbox is 'Unchecked' when it is actually checked.  It's like the state of the checkbox never gets changed.

I am not sure what to do.  

Any help is appreciated.
Comment
Watch Question
Developer
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE