Listbox with DataSource automaticly select item

Joined
Jul 30, 2009
Messages
2
Reaction score
0
Hello,

I have ListBox and the DataSource is link to a BindingList<T>. When I add a first object to my BindingList, it is correctly reflected in the ListBox, but my problem is that the element is automaticly "selected". I put it in quotes, before in apperence it is Selected, but the event of the ListBox indicating that the selected item changed is not called.

If I do not use DataSource, but use the Items.Add() of the ListBox, when an first item is added, it is not selected. First, what I want while using the DataSource.

Is can't do anything about that, my second problem is that the event for an item selected is not triggered.

Thank you.
 
The only solution I have found so far, is to change the SelectedIndex to -1 immediately after adding the data to the BindingList. It not so bad because I add the data in the same form that the ListBox is in, but I don't find that very clean.

I've found out that the Event triggered when adding something to the "DataSource", is the SelectedValueChanged, but I can't put it to null. It seem there must always be a selected value...
 
Last edited:
Back
Top