0
For Each itm As ListViewItem In ListView1.Items
        If itm.Text <= CStr(56) Then
            itm.BackColor = Color.Orange
        Else
            itm.BackColor = ListView1.BackColor
        End If
    Next

this codes change background color of all items in listview....but i just want to change the forecolor mu value of stocks in listview in a column stocks..not all column..pls guys help me:(

4
Contributors
5
Replies
18
Views
1 Year
Discussion Span
Last Post by Reverend Jim
1

forecolor mu value of stocks in listview in a column stocks

In C# this works for SubItems. Am sure you can convert it to what you need in VB.NET:

lvItem.UseItemStyleForSubItems = false;
lvItem.SubItems[2].BackColor = Color.Orange; // 2 should be the right column index
0

thank you very much 4 ur codes:)..but not working..
my problem is this codes select all items ni all column..
( For Each itm As ListViewItem In ListView1.Items) 'select all items

i want to select only one column to change a backcolor:)

tnx guys godblessyou:) hope u help me to solve this:)

1

Use a DataGridView rather than a ListView. That would allow you to change colours of individual cells in any way that you want. To change an individual cell you code

dgvData.Rows(row).Cells(col).Style.BackColor = Color.Thistle

replacing row& col with the 0-relative row and column numbers.

Edited by Reverend Jim

0

Simply replace BackColor with ForeColor, this will color your matching Item with a specified color from the code you posted.

Edited by Mr.M

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.