Avatar of Jacque Scott
Jacque Scott
Flag for United States of America

asked on 

C# CheckState of a Checkbox

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.
ASP.NETC#

Avatar of undefined
Last Comment
Dustin Saunders

8/22/2022 - Mon