ListBox, DataSources and IBindingList

A

Andreas Zita

Hi all,

I have a frustrating problem with ListBox:

I am adding a custom collection (MyColl : CollectionBase) as the DataSource
for a standard ListBox control. When selecting an item the name of it
appears (DataBound Property) in a TextBox to allow editing. The thing is
that when Im editing the name in this TextBox I continously update the
databound property
(TextBox.DataBindings["Text"].BindingManagerBase.EndCurrentEdit() so that
the text in the ListBox always should reflect the changes made in
"realtime". However, the ListBox only seem to update when it is focused
again? Why isnt the ListBox updating instantly when a property is changed?

I tried to solve this problem by letting MyColl implement the IBindingList
Interface and having each listobject telling MyColl when a property had been
updated. MyColl then fires a OnListChanged event with the ListChangedType as
ItemChanged. However, this doesnt seem to update only the changed item but
the entire ListBox? Before, as without IBindingList, when the ListBox
updated it only updated the changed item and also did it in very "silent".
When updating through OnListChanged the ListBox "flashes" and moves the
scrollposition around just as if the list would have been rebuilt entierly.
I cant have that happen every time a key is pressed and the property is
updated. I want it to be "silent" and smooth.

Is there any way of having the "silent" updating of CollectionBase but as
frequent as the OnListChanged of IBindingList???

/Andreas Zita
 
A

Andreas Zita

I notices another very strange behavior: When using
OnListChanged(ListChangedType.ItemChanged, N)... N apparently should be the
new size of the collection. When complying to this (using N = List.Count)
the list isnt updating at all. When having some other value it may update or
not depending on what the scrollposition is ... ? I dont get this at all ...

/Andreas Zita
 

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