3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by MeSam0804
0
Dim grp As ListViewGroup
 grp = ListView1.Groups.Add("String", "String")

 Dim item As ListViewItem = New ListViewItem(grp)
        Dim remain As Integer
        Math.DivRem(ListView1.Items.Count, 2, remain)
        If remain <> 0 Then
            item.BackColor = Color.White
        Else
            item.BackColor = Color.WhiteSmoke
        End If

        item.Text = "Item String"
        item.SubItems.Add("sub item" )

        ListView1.Items.Add(item)
0

I use the Mod operator which returns the remainder.

Dim lvi As New ListViewItem
lvi.Text = "Hello"
If ListView1.Items.Count Mod 2 = 0 Then
    lvi.BackColor = Color.white
Else
    lvi.BackColor = Color.LightGray
End If
ListView1.Items.Add(lvi)
0

if you wanna have such list view items you should make a listview group

Dim grp As ListViewGroup

then you need items and maybe subitems for each row that is included in your group

Dim item As ListViewItem = New ListViewItem(grp)

you must apply your property on your items
and at the end add that item into your listview

thats not hard to understand :)

Edited by MeSam0804: mustapply = must apply

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.