How to change the ListViewItem.Selected default color

L

LagartijaNick

Question:

I have a ListView in which I'm selecting a ListViewItem based on the
value of a textbox. On my XP machine (with default color scheme) the
..Selected row is a noticable grey (back color of ListView is white).
However, on a custom Win2K desktop, the selected item is a faint grey
and the users can barely see the highlighted row. The custom desktop
settings have been locked down (ie. cannot be changed via Control
Panel etc.)

How do I programatically change the color of a selected row? (If I
change the back color of the ListViewItem, the .Selected row still
shows as grey (when you click on another row, the color of the
previously selected row changes to the new color - but that's not what
I want)

Code snippet:

Dim lv as ListView = CType(lvProcessed, ListView)
Dim index as Integer = 0

lv.SelectedItems.Clear()
Dim _enumerator As IEnumerator = lv.Items.GetEnumerator

While _enumerator.MoveNext()
Dim _item As ListViewItem = CType(_enumerator.Current,
ListViewItem)
If (_item.SubItems(2).Text = SearchText) Then
_item.Selected = True
index = _item.index
_item.EnsureVisible()
End If
End While


There's probably an easy solution, but I haven't seen it yet! Any help
appreciated...
 
I

Inge Henriksen

I think you cant, it uses SystemColors.HighLight I think, and you can't set
it directly as I know of.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top