Link to home
Start Free TrialLog in
Avatar of Jason
JasonFlag for Australia

asked on

objectlistview changing text of cells

I need to change color of text
so if value of Cp is great than 1.5 the text is to be red otherwise text is to be black.
 If Cp > 1.5 Then
                    Form1.ObjectListView1.Items(ic).SubItems(6).ForeColor = Color.Red
                Else
                    Form1.ObjectListView1.Items(ic).SubItems(6).ForeColor = Color.Black
                End If

Open in new window


Can any one help as this code does not work
Avatar of it_saige
it_saige
Flag of United States of America image

Where are you handling this at Renegade?

-saige-
Avatar of Jason

ASKER

at the time it updates the listview

Sub ProcessMoneyGap()
        For ic As Integer = 0 To Form1.ObjectListView1.Items.Count - 1
            If ic <> Form1.ObjectListView1.Items.Count - 1 Then
                Dim OldVal = Form1.ObjectListView1.Items(ic).SubItems(0).Text
                Dim NewVal = Form1.ObjectListView1.Items(ic + 1).SubItems(0).Text
                Dim CalcPercent
                Dim Cp = Math.Round(((NewVal - OldVal) / OldVal) + 1, 2, MidpointRounding.AwayFromZero)

                CalcPercent = Math.Round(((NewVal - OldVal) / OldVal * 100), 2, MidpointRounding.AwayFromZero)

                Form1.ObjectListView1.Items(ic).SubItems(6).Text = Cp & " / " & CalcPercent
                If Cp > 1.5 Then
                    Form1.ObjectListView1.Items(ic).SubItems(6).ForeColor = Color.Red
                Else
                    Form1.ObjectListView1.Items(ic).SubItems(6).ForeColor = Color.Black
                End If
            End If
        Next
    End Sub

Open in new window

SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason

ASKER

saige that way doesn't fit with how i coded this process.
is there another way to do this that fits into the code i have written
Avatar of Jason

ASKER

Saige are you able to help with an alternative
Avatar of Jason

ASKER

can i put Dim i As Integer = Form1.ObjectListView1.Columns.IndexOf(olv1MoneyGap) is a module or class other than form class

olv1MoneyGap errors
User generated image
Potentially.

If possible, can you provide a copy of your current project with some valid test data.  I can take a look at it this weekend.

-saige-
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason

ASKER

Saige is a great help
But with this one I solved myself to fit my existing code