Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I get results to alternate coloring/shading in a listview plus one odd ball of a different color.

Posted on 2005-05-07
2
Medium Priority
?
267 Views
Last Modified: 2012-05-05
Friends,

thanks to Desp (a member of this forum) I am getting alternating colors perfectly; however, if I knew the exact position, could I make it, and only it, a different color from the others.  I want to make it stand out, so that it is easily recognizable.

Scenario:

position 0 - 11 alternate between white and light blue, but at position 12, I'd like it to be yellow, and then the remainder be the same alternating colors of white and light blue.  How do I do that?

Regards and thanks in advance!


While dr.Read()

            i = (i + 1)
            li = lvQualificationsStandings.Items.Add(i)

            If dr.Item("QualID") <> Nothing Then

                If i Mod 2 = 0 Then
                    li.BackColor = Color.White
                Else
                    li.BackColor = Color.LightBlue
                End If

                li.SubItems.Add(dr("Car Number"))
                li.SubItems.Add(dr("Driver"))
                li.SubItems.Add(dr("QualifyingSpeed"))
                li.SubItems.Add(dr("Status "))
                li.SubItems.Add(dr("OnTheBubble"))
            End If
0
Comment
Question by:indy500fan
2 Comments
 
LVL 34

Accepted Solution

by:
Sancler earned 2000 total points
ID: 13950978
While dr.Read()

            i = (i + 1)
            li = lvQualificationsStandings.Items.Add(i)

            If dr.Item("QualID") <> Nothing Then

                if i = 12 Then '<<< NEW LINE
                    li.BackColor = Color.Yellow '<<< NEW LINE
            ElseIf i Mod 2 = 0 Then '<<< AMENDED LINE
                    li.BackColor = Color.White
                Else
                    li.BackColor = Color.LightBlue
                End If

                li.SubItems.Add(dr("Car Number"))
                li.SubItems.Add(dr("Driver"))
                li.SubItems.Add(dr("QualifyingSpeed"))
                li.SubItems.Add(dr("Status "))
                li.SubItems.Add(dr("OnTheBubble"))
            End If
0
 

Author Comment

by:indy500fan
ID: 13951531
Sancler,

Perfect, and I took it one step further to take the position from a textbox.  If the position in the textbox is nothing, then it defaults to the standard blue/white combo.

Thanks a bunch!

 While dr.Read()

            i = (i + 1)
            li = lvQualificationsStandings.Items.Add(i)

            If dr.Item("QualID") <> Nothing Then

                If txtPosition.Text = Nothing Then
             
                    If i Mod 2 = 0 Then
                        li.BackColor = Color.White
                    Else
                        li.BackColor = Color.LightBlue
                    End If

                    li.SubItems.Add(dr("Car Number"))
                    li.SubItems.Add(dr("Driver"))
                    li.SubItems.Add(dr("QualifyingSpeed"))
                    li.SubItems.Add(dr("Status "))
                    li.SubItems.Add(dr("OnTheBubble"))

                Else
                    If i = txtPosition.Text Then
                        li.BackColor = Color.Yellow '<<< NEW LINE
                    ElseIf i Mod 2 = 0 Then '<<< AMENDED LINE
                        li.BackColor = Color.White
                    Else
                        li.BackColor = Color.LightBlue
                    End If

                    li.SubItems.Add(dr("Car Number"))
                    li.SubItems.Add(dr("Driver"))
                    li.SubItems.Add(dr("QualifyingSpeed"))
                    li.SubItems.Add(dr("Status "))
                    li.SubItems.Add(dr("OnTheBubble"))
                End If
            End If
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question