Link to home
Start Free TrialLog in
Avatar of CodeWrangler
CodeWrangler

asked on

ComboBox issues in .Net 2008 C# Windows Forms application

I have a simple combobox that is populated using a dataset which gets data from a SQL server. This combobox (cmb1) is populated during the form's Load event

On the cmb1_SelectedIndexChanged event, I have another combobox (cmb2) populating based on the cmb1's value.

Problem is, whe the form loads, the second combo box is getting populated with the first element in cmb1. I need cmb2 to remain blank until the user selects something in cmb1.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CodeWrangler
CodeWrangler

ASKER

Yep, thats is exactly what I am doing. As a temporary workaround, I am putting something in index 0 which I know will not return results from the database.
Figured it out. Thanks Kaufmed. Even though you suggested something I had already tried, it got me thinking on something I did incorrectly.
In case someone wanders in here for any combobox issues.. if you are wondering why the _SelectedIndexChanged event is firing when trying to populate comboxes using SQL.. use:

if (cmbKey2.SelectedIndex > -1 && cmbKey2.ContainsFocus == true)
            {....}