Unchecking checkboxes programmatically

234 Views Asked by At

I have a certain requirement that, if the first checkbox in a row of checkboxes is unchecked, then all the other checkboxes must be unchecked. Here is a sample UI

I am using DevExpress 21.2.3 and RepositoryItemCheckEdit as the check box

Can anyone help me to achieve this functionality?

Thanks

2

There are 2 best solutions below

0
sjuhyeon On

Create a list of check boxes. Then If checkBox1 is equal to false(unchecked), set the check boxes in list to false.

if( checkBox1.Checked== false ) 
{
  for(int i = 0; i <= checkBoxes.Count; i++) 
  {
    checkBoxes[i].Checked = false;
  }
}
0
GingerCRO On

you can do it simply like this:

  • firstly, create a few checkboxes in your program: enter image description here

  • secondly, declare a CheckBox array in the class and, in the Load() method, initialize all checkboxes to created CheckBox array: enter image description here

  • finally, in the CheckedChanged() method, write code which will check or uncheck all checkboxes, depending on the first checkbox. enter image description here