Problem w/multiple ListBoxes on one form

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
I have a form with 5 Ownerdraw Listboxes, each of which gets populated with data from a single array. ListBox1 receives data from the 1st 30 array elements, Listbox2 from the next 30... and so on. When I try to populate ListBox2, ListBox2 recieves it's data, but ListBox1 also receives the same data and overwrites the data previously in ListBox1. I am using seperate eventhandlers for each Listbox:

Private
Sub ListBox1_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem

PrivateSub ListBox2_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox2.DrawItem

... and so on. When it's time to begin populating ListBox2, I use ListBox2.Focus to shift focus to ListBox2. I've tried using ListBox1.BeginUpdate() to try to freeze the data in ListBox1, but that just clears the entries in ListBox1 when ListBox2 begins populating. Oddly, everything works OK if I insert a messagebox between populating ListBox1 & ListBox2. 'Problem is I don't need a messagebox there...

... Anybody know the proper way to do this ?

 
Bizarre, but have heard of this before. Though i've not been able to explain it. If you don't want to use a messagebox there then use...

VB.NET:
Expand Collapse Copy
Application.DoEvents
 
Back
Top