Click here to Skip to main content
12,891,469 members (52,754 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Windows form
Hi I'm trying to get my comboBox to become visible once a certain item is selected in my listbox.
I have this code:

    ComboBox.Visible = true;

This isn't working... Any other ideas?
Posted 9-Sep-12 14:45pm
Updated 9-Sep-12 14:46pm
Wes Aday104.2K
Wes Aday 9-Sep-12 20:49pm
And "isn't working" means what exactly? The code is never called? SelectedItems never contains "Tea"? Combobox never becomes visible? The code ran and your hard drive melted?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Move the code to click event it will work.

private void listBox1_Click(object sender, EventArgs e)
 if (listBox1.SelectedItems.Contains("Tea"))
   comboBox1.Visible = true;

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Sorry... When I run the program, and Tea is selected, the comboBox does not become visible.
However, if I change the code to
ComboBox.visible = true;
And I select tea, the comboBox appears. But it appears even if I do not select tea.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 10 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100