0

How do I open a Form using a Combobox In C++?

How do I open a Form using a combobox? If I have 3 Values such as apples, oranges and I want to open a form if the user choses apples and another form if the user choses oranges.

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

 FrenchFries ^ newfrm = gcnew FrenchFries();

 if (comboBox1::Text = "French Fries") 
newfrm->Show();

 else 
Form::Close();

This is the error that I get.

error C2451: conditional expression of type 'void' is illegal
error C2653: 'comboBox1' : is not a class or namespace name
8 hours ago
- 4 days left to answer.

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Milton Neal
0

Not used c++ dotnet but I'd imagine there should be a property called:

comboBox1.name or something?

Also you need to use the double equals sign to compare strings...

==

0
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
             {
                FrenchFries ^ newfrm = gcnew FrenchFries();
                if (comboBox1->Text == "French Fries") 
                    newfrm->ShowDialog(this);

                else 
                    this->Close();
             }

Milton

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.