Create new combo boxes based on items selected in preview combo box
I am trying to write a very simple Windows Forms application program using Visual C++ 2005. The title says it all but I would like to expand on it a little.
What I am ultimately trying to do, is give a list of several different options (through the drop down combo boxes) that lead to more options (more combo boxes). For example, lets say that I have 1 combo box to start with 2 items in the list (yes and no). I need to be able to create a new combo box with their own unique items based on what was selected. If 'yes' was selected then I need to create a combo box that lists 4 or 5 items. If 'no' is selected then I need to create a different combo box with 1 or 2 items.
Ultimately, when all the required choices have been made, I need to print out the answers chosen to a file.
I am not new to programming but I am new to using Visual C++ 2005 (I am used to using Dev-C++ and Code::Blocks). Windows programming is a bit new to me as well (currently on chapter 3 of "Programming Windows" by Charles Petzold). So , here is a summary of what I am needing to know.
1. How do I create a combo box based on which item was selected from a previous combo box.
2. What is the least time consuming way of writing all of the chosen answers to a file?
3. Reading the book I listed above, am I on the right track to learning how to use and code with Visual C++ 2005?
Wooohooo! Solved part of it myself!
Ok, after spending several days toying with this I managed to figure out part of the problem myself.
Instead of creating new combo boxes based on the items selected in a previous combo box I changed it up a bit. I have 1 combo box with a list of several items (labled 1-5 for simplicity reasons). Then I have a series of checkboxes that are disabled (Enabled = false). Then I just plugged in this code and got the results I was looking for ...
Code:
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
if (this->comboBox1->Text == "1"){
this->checkBox1->Enabled = true;
}
else {
this->checkBox1->Enabled = false;
}
}
For the first time I would like to thank everyone for not helping me so far. I learned a lot of things (like how much normal C++ works with Visual C++ 2005 almost flawlessly). I guess thats the magic of .NET?
Anyhow, part of the problem still remains. I need to collect all the information from ComboBoxes, CheckBoxes and TextBoxes and output all the information into a file. Since I pretty much know how to get variables and values to a file with C++ I don't think I should have to much trouble doing it with Visual C++. :)
Oh the irony! Thanks for nothing! :)