|
-
Dec 22nd, 2009, 08:37 AM
#1
Thread Starter
Not NoteMe
Databound Listbox SelectedItem
I have a listbox bound to a datasource, which gets updated.
When it does the selected index remains the same. Meaning, that the selected item is different, since the order/number of items could change as the datasource is updated.
Is there any way round this?
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Dec 22nd, 2009, 07:10 PM
#2
Re: Databound Listbox SelectedItem
Exactly what is the control bound to? Can you provide some example code we can execute to demonstrate the issue?
-
Jan 6th, 2010, 07:02 AM
#3
Thread Starter
Not NoteMe
Re: Databound Listbox SelectedItem
It's bound to a class derived from BindingList of custom objects, which only every has items added or removed (the list isn't cleared and repopulated).
All i did was add AddRange / RemoveRange functions as below:
Code:
public void AddRange(IEnumerable<T> Items, IEqualityComparer<T> Comparer)
{
foreach (T Item in Items)
{
if (!this.Items.Contains(Item, Comparer))
this.Items.Add(Item);
}
OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, 0));
}
I may have answered my own question. Is this issue caused by me using the Reset listchangedtype enumeration value?
I used that figuring no others were appropriate since it wasn't just one index that was changing.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|