|
-
Aug 21st, 2006, 03:44 AM
#1
Thread Starter
New Member
Combobox
I have a windows form with 2 comboboxes. The first combobox is visible while the other is not, until when I select a value in the first combobox, the second combobox will appear. How do I do that?
-
Aug 21st, 2006, 04:01 AM
#2
Re: Combobox
Handle the SelectedIndexChanged event of the first ComboBox:
Code:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
this.comboBox2.Visible = (this.comboBox1.SelectedIndex != -1);
}
-
Aug 21st, 2006, 07:44 PM
#3
Thread Starter
New Member
Re: Combobox
Thanks for your reply, but it doesn't work. I first set the visible property of the second combobox to false and added your code, but it doesn't work. The second combobox had appeared when the form loads. How?
-
Aug 21st, 2006, 08:03 PM
#4
Re: Combobox
You can see from the code that the second ComboBox is visible if an item is selected in the first ComboBox and not visible if an item isn't selected. Assuming that you've set the Visible property of the second ComboBox to False in the designer, if your second ComboBox is visible then you have an item selected in your first ComboBox, plain and simple.
Last edited by jmcilhinney; Aug 21st, 2006 at 09:18 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|