Cuando añado un item al listrview, hace un flash, un efecto muy desagradable.
Lo he intentado TODO,
AddRange,
Suspendlayout,
Me.Doublebuffered, y por último
BeginUpdate... Nada lo ha resuelto.
Problems += 1
str(0) = Problems
str(1) = str(1).Substring(2)
itm = New ListViewItem(str)
InvokeControl(ListView, Sub(x) x.BeginUpdate())
InvokeControl(ListView, Sub(x) x.Items.Add(itm))
InvokeControl(ListView, Sub(x) x.EnsureVisible(ListView.Items.Count - 1))
InvokeControl(ListView, Sub(x) x.EndUpdate())
end for...
Esto es otra variante del código, aquí noto cierta mejora (Flashes más cortos):
Private Sub AddItemToListView()
str(0) = Problems
str(1) = str(1).Substring(2)
itm = New ListViewItem(str)
ListView.SuspendLayout()
InvokeControl(ListView, Sub(x) x.BeginUpdate())
InvokeControl(ListView, Sub(x) x.Items.Add(itm))
InvokeControl(ListView, Sub(x) x.EnsureVisible(ListView.Items.Count - 1))
InvokeControl(ListView, Sub(x) x.EndUpdate())
ListView.ResumeLayout()
If NumberIsOdd(Problems) Then
itm.BackColor = Color.FromArgb(15, 15, 15)
Else
itm.BackColor = Color.FromArgb(30, 30, 30)
End If
End Sub
Sé que el AddRange y BeginUpdate están pensados para añadir varios items, pero como podeis comprobar en el ejemplo es que yo necesito añadirlos uno por uno.
¿Que puedo hacer?