Advertisement

05.21.2008 at 11:00AM PDT, ID: 23421877
[x]
Attachment Details

Change individual listviewitem/subitem colors

Asked by sgaggerj in Microsoft Visual Basic.Net

Tags: VB.Net 2005

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.TypeDescriptor.GetConverter(GetType(Color)).GetStandardValues()
                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.ListViewSubItem
                        l.Text = c.Name
                        l.BackColor = Color.White
                        l.ForeColor = Color.Black

                        lv1.SubItems.Add(l)

                        SystemList.Columns(0).ListView.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?Start Free Trial
[+][-]05.21.2008 at 11:53AM PDT, ID: 21617911

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: VB.Net 2005
Sign Up Now!
Solution Provided By: YoungBonzi
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.21.2008 at 12:14PM PDT, ID: 21618099

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628