473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to change the ListViewItem.Selected default color

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...

Nov 21 '05 #1
1 4236
I think you cant, it uses SystemColors.HighLight I think, and you can't set
it directly as I know of.

"LagartijaNick" <La***********@home.net> skrev i melding
news:q3********************************@4ax.com...
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...


Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kenny | last post by:
I have populated the ListViewItem for display into 5 column headers. I have set aside two columns to be populated after a button is selected for recalculation. How do I assign information to the...
0
by: LV | last post by:
Hello, I would like to manually set one of my list view items as selected. When this item is set, I would like for a method to execute. I have a delegate on the list view for SelectedIndexChanged....
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
5
by: Jax | last post by:
Dear all, I have a list view, i dont like this list view very much anymore as it hasn't been the easiest object to use thus far. Now i like it even less. I have a problem with it, I wish to...
2
by: Fritz | last post by:
I know it, I know it. It's come up a lot. I've done the Googling, but the standard answer doesn't do what I expect it to. For the record, the standard answer is: "Set the Selected property of a...
0
by: Kluch | last post by:
I am trying to select and focus single ListViewItem and can't seem to do so, here is my code: IEnumerator * itemList = mLsvMyList->Items->GetEnumerator(); while (itemList->MoveNext()) {...
3
by: n. Smith | last post by:
Hi All, Is it normal that the ListView fires the selectedinexchange event twice? I have a LvLoaners list view item that updates 3 text boxes (code below), when I click on an item. I have set...
3
by: Steve Long | last post by:
I hope this isn't too stupid of a question but I'm looking for a way to change an item in a listview control when the mouse moves over it. I'd like to change its color and underline it for a...
6
by: Padu | last post by:
I've been searching the newsgroup for an answer but probably with the wrong keywords... Imagine that I have a ListView with some items and the listview view is Details. How do I move an item up...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.