sgaggerj
asked on
Change individual listviewitem/subitem colors
Hi All,
I am attempting to re-create the color chooser that is in the IDE (the one where you click BackgroundColor and the color chooser pops up with three tabs Custom, Web and System)
I am using a ListView to do the System tab right now.
I have it set to Detail view and have 2 columns.
One column will be the color, and the 2nd column will be the color name.
here's what i've got so far:
With .TabPages(1)
' get the colors
Dim clr() As Color
Dim ic As ICollection = System.ComponentModel.Type Descriptor .GetConver ter(GetTyp e(Color)). GetStandar dValues()
ReDim clr(ic.Count - 1)
ic.CopyTo(clr, 0)
SystemList.Items.Clear()
For Each c As Color In clr
If c.IsSystemColor Then
Dim lv1 As New ListViewItem()
lv1.BackColor = c
' lv1.subitems(0).backcolor= c ' this doesn't help either.
Dim l As New ListViewItem.ListViewSubIt em
l.Text = c.Name
l.BackColor = Color.White
l.ForeColor = Color.Black
lv1.SubItems.Add(l)
SystemList.Columns(0).List View.Items .Add(lv1)
End If
Next
End With
this works, with one problem. The entire row is the color 'c', the subitem does not get a background color of White.
(it does when you click on it's corresponding column 0 - it changes to white, but when you click off it gets its original background color)
any suggestions?
I am attempting to re-create the color chooser that is in the IDE (the one where you click BackgroundColor and the color chooser pops up with three tabs Custom, Web and System)
I am using a ListView to do the System tab right now.
I have it set to Detail view and have 2 columns.
One column will be the color, and the 2nd column will be the color name.
here's what i've got so far:
With .TabPages(1)
' get the colors
Dim clr() As Color
Dim ic As ICollection = System.ComponentModel.Type
ReDim clr(ic.Count - 1)
ic.CopyTo(clr, 0)
SystemList.Items.Clear()
For Each c As Color In clr
If c.IsSystemColor Then
Dim lv1 As New ListViewItem()
lv1.BackColor = c
' lv1.subitems(0).backcolor=
Dim l As New ListViewItem.ListViewSubIt
l.Text = c.Name
l.BackColor = Color.White
l.ForeColor = Color.Black
lv1.SubItems.Add(l)
SystemList.Columns(0).List
End If
Next
End With
this works, with one problem. The entire row is the color 'c', the subitem does not get a background color of White.
(it does when you click on it's corresponding column 0 - it changes to white, but when you click off it gets its original background color)
any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You rock!
thanks!
J