List View Cololurs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr. B

    #1

    List View Cololurs

    I've not programmed for a while in VB 2003... but I've decided to modlfiy a
    Project I have.

    Seems simple enough... I've a List Box... I fill it with about 30 lines of
    data (3-4 columns).

    What I want to do is to be able to List the ROWS of data either a RED or GREEN
    colour depending upon an IF statement.

    So... IF X =< myVariable then Row would be GREEN ELSE Row would be RED.

    Orignally (before I tried to change the Colour) I had:

    'Display All Results

    LvItem = New ListViewItem
    LvItem.Text = reqWire
    LvItem.SubItems .Add(AcVolts)
    LvItem.SubItems .Add(AcVoltLoss )
    lvResults.Items .Add(LvItem)


    Now I've (I get a colour... but all rows are the same):

    'Display All Results

    Dim lvs As New ListViewItem.Li stViewSubItem
    Dim LItem As ListViewItem
    Dim nwClrA, nwClrB As Color
    nwClrA = Color.PaleGreen ' Equal to or Less Than
    nwClrB = Color.Salmon ' Greater Than

    LvItem = New ListViewItem
    LvItem.Text = reqWire
    LvItem.SubItems .Add(AcVolts)
    LvItem.SubItems .Add(AcVoltLoss )
    If AcVoltLoss = maxVd Then
    ' Change Color of Items
    lvs = LvItem.SubItems (0) ' Required Wire
    lvs.BackColor = nwClrA
    lvs = LvItem.SubItems (1) ' Volt Loss
    lvs.BackColor = nwClrA
    lvs = LvItem.SubItems (2) ' Volt Loss %
    lvs.BackColor = nwClrA
    Else
    lvs = LvItem.SubItems (0) ' Required Wire
    lvs.BackColor = nwClrB
    lvs = LvItem.SubItems (1) ' Volt Loss
    lvs.BackColor = nwClrB
    lvs = LvItem.SubItems (2) ' Volt Loss %
    lvs.BackColor = nwClrB
    End If ' Update ListView
    lvResults.Items .Add(LvItem)

    So what am I doing wrong??

    Thanks in advance!

    BruceF
Working...