mardi 18 octobre 2016

Retrieve indeterminate state from checkbox Winforms

I'm using Winforms and i am having trouble to retrieve indeterminate state from a checkbox. it always return "unchecked"...

I use this code to set checkbox to indeterminate when the form load :

 checkBox.CheckState = CheckState.Indeterminate;

it works.

Then when i click on the checkbox,"CheckedChanged" event is firing and i want to do nothing if state is indeterminate. But it return state "unchecked" while checkbox is displayed as "indeterminate"..

here is how i try to retrieve checkbox state :

CheckBox c = sender as CheckBox;
  if (c.CheckState == CheckState.Indeterminate)
        {
            MessageBox.Show("Nope");
        }

I did not find a solution except in WPF but i use Winforms..

Thanks for taking time to help me.




Aucun commentaire:

Enregistrer un commentaire