problem with ComboBox.DroppedDown

May 14 2008 5:55 PM
First of all, I'm using Visual Studio 2005, C#. So, I've got this ComboBox called cbPeople on a Form, and when the user types in a value and presses enter, I run a query and populate the combo box with selections, which works fine. My problem is that once the query is run, I want the drop down to be DOWN so that the user sees the selections and can choose one. So I use the DroppedDown property and set it to true.

My problem is that after the drop down drops down, immediately it goes back up again, and nothing I've managed to do has been able to keep it down! Any suggestions will be whole-heartedly appreciated!

Here's the code of my KeyPress event where the issue lies.

private void cbPeople_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (System.Char)Keys.Enter)
{
cbPeople.DataSource = _oc.SearchContacts(cbPeople.Text);
cbPeople.DroppedDown = true;

}
}

I've tried doing a cbPeople.Focus() at various points, but nothing Iv'e done has gotten that box to stay dropped down!

Thank you!
Joshua

Answers (2)