Displaying forms 2&3 from a combo box on form 1
I understand that my problem is probably really basic but any help would be greatly appreciated. Anyway, I have form1, form2, and form3. On form1 there is a combo box with two selectable values: form2 and form3. How would I go about connecting the actual forms to the selectable values in the combo box, so that selecting a particular value will open the corresponding form?
Manikavelu VelayuthamPosted Sep 9, 2010, 3:43 AM
Hope this code would help you a lot and dont forget to mark this answer.
if (comboBox1.SelectedItem.ToString().Equals("Form2"))
{
Form2 objForm = new Form2();
objForm.Show();
}
else if (comboBox1.SelectedItem.ToString().Equals("Form3"))
{
Form3 objForm = new Form3();
objForm.Show();
}
Manikavelu VelayuthamPosted Sep 9, 2010, 3:47 AM
Frank MillsPosted Sep 9, 2010, 3:34 AM
objForm2.Show();
This particular string of code does help me to access Form2 from Form1, however, my problem is that I have 3 forms and I need to be able to access Form 2 and 3 from a combo box on Form 1. Therefore, if I simply plug in the above string of code, any value that I choose within the combo box only takes me to form 2. How do I make it so that selecting "form 1" or "form 2" from within the combo box will open the corresponding form?
Manikavelu VelayuthamPosted Sep 9, 2010, 2:57 AM
objForm2.Show();
Hope this code would help you.
Frank MillsPosted Sep 9, 2010, 2:55 AM
Manikavelu VelayuthamPosted Sep 9, 2010, 2:41 AM
There you need to create an instance of the Form2 Or Form3 based on the selection of the combo box.
Finally you should show the form using Form2.Show or Form3.Show