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

  • Thread starter Thread starter Alex Stevens
  • Start date Start date
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
 
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
 
Back
Top