[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

listbox/listview - content drawing problem

AlexS

10/27/2003 10:52:00 PM

Don't know if this is known or not - I can't find anything describing my
issue.

I fill standard listbox in form Load event handler using loop with
lb.Items.Add(someString) inside BeginUpdate/EndUpdate - exactly as MS
prescribes in MSDN samples. Except that immediately after BeginUpdate I
issue listbox.Items.Clear(); Then follows the adding loop.

Problem is that sometimes listbox is displayed as empty one - no entries -
after addition of 1 or more entries in this loop. Problem happens
irregularly. Usually in 1 case from around 100.

I start to wonder if this is related to Load event and possibly sequencing
of internal messages in 1.1. Anybody has any clue what could be the reason?

I tried to use listbox.Invalidate() and listbox.Update() after final
EndUpdate - however found out that this doesn't exclude my problem
completely. Today once again I got empty listbox on screen after adding 1
entry. When I intercept loop in debugger usually everything is displayed Ok.
The only thing which I was able to remark so far is that usually this
problem happens when number of added entries is less than number of entries,
which fit in listbox page. E.g. if listbox is able to show 20 entries I can
expect this problem when I add less than 20 entries in form.Load event
handler. Similar with Listview control.

Thanks!
Alex


1 Answer

jb huber

11/5/2003 5:38:00 PM

0

I had the same problem. To solve it without loosing speed, instead of
adding directly the item in the listbox, I add it to an arrayList. Then,
I make a listBox.AddRange(list.ToArray()). The speed is conserved and
this works...
Why does it not work with BeginUpdate() ? No idea...

JB

*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!