I am iterating through an arraylist to populate two columns of a listview control. Code:
As this listview is populated (it takes maybe 3-4 seconds), even though it runs on a background worker thread, it makes the form blink very fast while it fills the listview display and it looks bad.
I used the following directive on form_load:
because this listview is created on the main program thread. Moving the fill function to another thread allows the form to be rendered, but now instead of just hanging for 4 seconds while this listview is populated, it blinks. I also moved the Split() call out of the loop, and it still blinks.
I'm happy to do this in a more elegant way, but I'll need code samples rather than URLs if possible.
VB.NET:
For i As Integer = 0 To arr.Count - 1
Dim item As String = arr(i)
'split into required values
Dim arrItem() = Split(item, "___")
Dim szNum As String = arrItem(0)
Dim szName As String = arrItem(1)
Dim lvItem As New ListViewItem(szNum, 0)
lvItem.SubItems.Add(szName)
listview1.Items.Add(lvItem)
Next
I used the following directive on form_load:
VB.NET:
Control.CheckForIllegalCrossThreadCalls = False
I'm happy to do this in a more elegant way, but I'll need code samples rather than URLs if possible.