Combobox not display selected item

M

Mark Boettcher

I am writing a Windows Form app in c# and I've populated a combobox with
values.

I click on the down arrow to display the list and the list of values
displays correctly. Once I select a value, the list disappears and the
selected value does NOT display as the selected item. If I click the down
arrow again and re-select the value, this time it displays.

What's wrong?

Thanks,
Mark
 
D

Dom

Check your code. Somewhere, you must have "Combobox1.SelectedIndex =
-1". There is really no other way for this to happen.

One way to check is to capture the event "SelectedIndexChanged" and
then set a break point there to see how the event is being fired.

Dom
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Check your code, see what methods are handling the selenctedindexchanged.
Also verify what you do ni that method, if you affect other controls's
status it's possible that the handlers of those other controls do the same
with the combo.
 
M

Mark Boettcher

I found my problem - in the course of executing the SelectedItemChanged event
I was clearing the combobox value list with .Items.Clear.

Txs,
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top