Bug In Combobox / listbox - SelectedIndex on form open!!

A

Alex Stevens

Hi All,

I've come across something which I think is a bug in the windows forms
combobox and listboxes.

I have a simple form which retrieves a datatable, and then set the
datasource of a listbox to the datatable.
I then set the displaymember / valuemember to the appropriate fields of the
datatable.
Then I set the selectedindex to -1

On a form opened with it's MDIParent set to an MDI container (a form in my
case), the first entry in the list is selected when the form is opened
(SelectedIndex = 0).
If the same form is opened without an MDI parent, the listbox displays as
you would expect, without anything selected and it's (SelectedIndex = -1).

Anyone else found this, and got a workaround?
I've seen some posts regarding the SelectedIndex changing on a tab, but
nothing about an MDIparent issue?

Any help or an alternative method of filling a combo / lisbox with a display
/ valuemember would be appreaciated.

Thanks

Alex Stevens
 
C

Cor

Hi Alex,

I tried it and had the same unwanted result as you, while when I replace
everything to the visible change event it works both the same.

Cor
 

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