Click to See Complete Forum and Search --> : Using Check Boxes (Newbie)


lp101
February 5th, 2009, 08:53 PM
I'm trying to write an app that will ask the user to select choices based on clicking check boxes. The app will determe what software app is appropiate based on their choices. For example

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if( checkBox1->Checked == true, checkBox4->Checked == true )
textBox1->Text = "Visual Studio";
}


How do I code a response if the user clicks on checkmarks that don't have a predetermined text value? I'll have 19 or so total check boxes. Thanks!

GCDEF
February 5th, 2009, 10:11 PM
You need to head over to one of the .net forums.

Marc G
February 6th, 2009, 04:02 AM
[ moved thread ]

lp101
February 6th, 2009, 06:35 PM
I'm trying to write an app that will ask the user to select choices based on clicking check boxes. The app will determe what software app is appropiate based on their choices. For example

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if( checkBox1->Checked == true, checkBox4->Checked == true )
textBox1->Text = "Visual Studio";
}


How do I code a response if the user clicks on checkmarks that don't have a predetermined text value? I'll have 19 or so total check boxes. Thanks!


I figured I could use the if,else command. for example

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if( checkBox3->Checked == true, checkBox4->Checked == true )
textBox1->Text = "Windows 2000";
else
textBox1->Text = "Windows 98";
}

This doesn't appear to be practical. With over 19 different checkboxes. I would have to code a response for many different cirumstances.

Marc G
February 7th, 2009, 05:36 AM
First, what are you trying with:
if( checkBox3->Checked == true, checkBox4->Checked == true )
I think you want to use AND operator as in:
if( checkBox3->Checked == true && checkBox4->Checked == true )
Or OR operator as in:
if( checkBox3->Checked == true || checkBox4->Checked == true )

For the selection, maybe you can use some kind of list of combinations. For example:
struct ASelection {
std::string strName;
std::vector<bool> vecRequiredCheckboxes;
};
std::vector<ASelection> vecPossibleSelections;
Then fill the vecPossibleSelections vector with ASelection structure where the embedded vecRequiredCheckboxes gives the required checkboxes that need to be checked. Then when the user clicks the button1 button, you iterate over the vecPossibleSelections vector to find the ASelection that matches the currently checked checkboxes.

lp101
February 7th, 2009, 09:15 AM
First, what are you trying with:
if( checkBox3->Checked == true, checkBox4->Checked == true )
I think you want to use AND operator as in:
if( checkBox3->Checked == true && checkBox4->Checked == true )
Or OR operator as in:
if( checkBox3->Checked == true || checkBox4->Checked == true )

For the selection, maybe you can use some kind of list of combinations. For example:
struct ASelection {
std::string strName;
std::vector<bool> vecRequiredCheckboxes;
};
std::vector<ASelection> vecPossibleSelections;
Then fill the vecPossibleSelections vector with ASelection structure where the embedded vecRequiredCheckboxes gives the required checkboxes that need to be checked. Then when the user clicks the button1 button, you iterate over the vecPossibleSelections vector to find the ASelection that matches the currently checked checkboxes.

Thans for your time. I believe I can work with the information you have provided me. It appears to be very helpful. Thanks again!