Hi,
I have a listbox which contains about 90 items, all short strings of about 5-6 characters.
In my code, I have an array of strings, which I am iterating through, and each one that matches to an item in the listbox I am setting to 'selected'.
The problem is, this process is taking way too long - for instance if I'm selecting 80 of the 90 items, it takes about 20 seconds.
I have tried different methods of setting the selection - looping through the objects looking for the match, then setting it to true;
using 'setSelected' based on location of match; using 'SelectedItems.Add' - they all take just as long to go through.
I tried adding 'SuspendLayout with no difference, and several other things.
The form on which the listbox resides has a large number of controls on it; I am guessing that maybe it's refreshing the screen between each selection - I seem to detect the screen flickering while I'm waiting for the code to finish.
Please advise on what I can try to get this to run quicker.
Thanks!
I have a listbox which contains about 90 items, all short strings of about 5-6 characters.
In my code, I have an array of strings, which I am iterating through, and each one that matches to an item in the listbox I am setting to 'selected'.
The problem is, this process is taking way too long - for instance if I'm selecting 80 of the 90 items, it takes about 20 seconds.
I have tried different methods of setting the selection - looping through the objects looking for the match, then setting it to true;
using 'setSelected' based on location of match; using 'SelectedItems.Add' - they all take just as long to go through.
I tried adding 'SuspendLayout with no difference, and several other things.
The form on which the listbox resides has a large number of controls on it; I am guessing that maybe it's refreshing the screen between each selection - I seem to detect the screen flickering while I'm waiting for the code to finish.
Please advise on what I can try to get this to run quicker.
Thanks!
Code:
Me.lstPossibleReports.Select()
Me.SuspendLayout()
Me.lstPossibleReports.SelectedItems.Clear()
For i = 0 To intSelectedRpts
If arrAccountInfo(0, intindex) = arrSelectedRpts(0, i) Then
If lstPossibleReports.Items.Contains(arrSelectedRpts(1, i)) Then
'lstPossibleReports.SetSelected(lstPossibleReports.Items.IndexOf(arrSelectedRpts(1, i)), True)
lstPossibleReports.SelectedItems.Add(arrSelectedRpts(1, i))
End If
End If
Next
Me.ResumeLayout()