Click here to Skip to main content
15,916,702 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have 5 check boxes that when checked and by pressing a button the checked items(actually their respective string) are added to a listbox

Now I need to compare with another set of check boxes (same string value as the other set)

I want to be able to gather the string of those checked fully matching or exceeding.

Example

CheckBox1 = "Jack"
CheckBox2 = "Alan"
CheckBox3 = "Adam"
CheckBox4 = "Mary"
CheckBox5 = "Andrew"

Assume I have the respective strings of CheckBox1 and CheckBox4 stored in my listbox and :

if on the other set of checkboxes I select CheckBox1 and CheckBox2 I want to get a message "*************"

if on the other set of checkboxes I select CheckBox1 and CheckBox4 I want to get a message "*************"

if on the other set of checkboxes I select CheckBox1 and CheckBox3 and CheckBox4 I want to get a message "*************"

Can any one help me out
Posted

C#
MessageBox.Show("*************", "Result");


Other than this it is difficult to help you as your question is not really clear.
 
Share this answer
 
It is very difficult to tell what you are trying to accomplish, so it is hard to know if this will be helpful or not (if not, please clarify your question)...

Iterate through the second set of checkboxes and see if their strings are in the list of strings from the listbox and if they are checked:

bool result1 = listBox1.Items.Contains(checkBox1.Text) && checkBox1.Checked;
bool result2 = listBox1.Items.Contains(checkBox2.Text) && checkBox2.Checked;


Then, use some if statements to take all the results and determine what message to display (see answer from Henry Minute for displaying message).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900