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.
 
Joined
Jul 30, 2009
Messages
2
Reaction score
0
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:

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

Similar Threads

Update bound ListBox 6
ListBox Populating Question 2
BindingContext Question 4
listbox 1
Unselect a ListBox 3
ListBox with collection 1
Beginner Data binding question 2
ListView vs ListBox 2

Top