Hello :

I 'd created a simple form , it consist of 2 set of checkboxs
1-6 checkboxes
2-6 checkboxes
I want to make a simple function determine if the first checkbox in set1 is checked it must test the checkboxes in set2 if the first is checked too or not .Any idea please???

Thanks inadvance...

Does this help?

 private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
            if (checkedListBox1.GetItemCheckState(0) == CheckState.Checked)
                checkedListBox2.SetItemChecked(0, true);

                checkedListBox2.SetItemChecked(0, false);


Hello :
Thanks for all answers but my ponit was :

group1 : checkbox1 checkbox2 checkbox3
group2 : checkbox4 checkbox5 checkbox6

all inside the form , I want to make a test function , make a test with the checked item and the item is against it , if checkbox2 is checked and checkox5 is checked too a messagebox appear , display a text ....etc
if not an error meassagebox appear ..etc not just checkbox 2&5 may be inside the form there are 50 checkbox's I can't in each item make a comperision .....can any one help???

Thanks in advance...

Hello Aminit,

Just a thought... have you considered using a binary value to represent each group ?
Set the Tag value for each checkbox with a hex value. Have a method OR the hex values for each checkbox (method will iterate through all checkboxes in a group) resulting in a single value for each group.

Hint: if you have each checkbox group contained in a panel or groupbox it makes it easier to iterate all checkboxes in that container rather than filter on all checkboxes on the form.

Once you have a single binary value for each checkbox group. You can (AND) the value with the other group(s) to see which combinations are checked as a single value.

If you have some known conditions (like that one which creates an error message), then you can AND that condition (as a binary value) to the checkbox group binary values.

Its just a matter of math.

If this sounds confusing, consider it this way. If you can represent Group A as a single value, then you can use simple boolean operators to compare against specific conditions you want to check.

// Jerry

Hello :
Thanks a lot