Hello,
I'm trying to make a list with alternating row colors like the one in the attached image but I'm having troubles making the rows with different colors, it only get the
last one.
I'm attaching the code:
Any help will be appreciated.
Kind regards.
Private Sub lstProductos_VisualItemCreating(sender As Object, e As ListViewVisualItemCreatingEventArgs) Handles listViewMSProductos.VisualItemCreating If Me.listViewMSProductos.ViewType = ListViewType.IconsView Then e.VisualItem = New CustomListViewItemIconType(IdApp) e.VisualItem.ImageLayout = ImageLayout.Center e.VisualItem.ImageAlignment = ContentAlignment.TopCenter e.VisualItem.TextAlignment = ContentAlignment.BottomCenter Else Dim aux As Integer = 1 For Each item In listViewMSProductos.ListViewElement.ViewElement.Items If aux Mod (2) = 0 Then e.VisualItem = New CustomListViewItemListType(Color.Red) Else e.VisualItem = New CustomListViewItemListType(Color.Blue) End If aux = aux + 1 Next End If End Sub
Public Class CustomListViewItemListType Inherits SimpleListViewVisualItem Public Sub New( pColor As Color) Me.BackColor = _color End Sub
End Class
