473,763 Members | 9,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change the ListViewItem.Se lected 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(lvProcess ed, ListView)
Dim index as Integer = 0

lv.SelectedItem s.Clear()
Dim _enumerator As IEnumerator = lv.Items.GetEnu merator

While _enumerator.Mov eNext()
Dim _item As ListViewItem = CType(_enumerat or.Current,
ListViewItem)
If (_item.SubItems (2).Text = SearchText) Then
_item.Selected = True
index = _item.index
_item.EnsureVis ible()
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 4266
I think you cant, it uses SystemColors.Hi ghLight I think, and you can't set
it directly as I know of.

"LagartijaN ick" <La***********@ home.net> skrev i melding
news:q3******** *************** *********@4ax.c om...
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(lvProcess ed, ListView)
Dim index as Integer = 0

lv.SelectedItem s.Clear()
Dim _enumerator As IEnumerator = lv.Items.GetEnu merator

While _enumerator.Mov eNext()
Dim _item As ListViewItem = CType(_enumerat or.Current,
ListViewItem)
If (_item.SubItems (2).Text = SearchText) Then
_item.Selected = True
index = _item.index
_item.EnsureVis ible()
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
1644
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 columns in the ListViewItem to be redisplayed? Please help. Thanks in advance!
0
1884
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. For some reason, when I set the listviewitem.Selected = true, the event is not fired. Here is my code: using System; using System.Windows.Forms; namespace DOMBuilder.GUI { public delegate void SelectedDomainObjectChangedHandler();
6
2408
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 say I have values selected for all three pull down menus. When I change the first "top-level" menu I want to reset both the second and third menus to the "default" state.
5
5604
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 change the selected index (i set selected to 1 so it can only select one) but it keeps telling me it is read only. Surely there must be a way round this!?!?
2
3707
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 ListViewItem to true." I also know from MSDN that the selection won't really take effect until the ListView has focus. My specific problem is that setting item.Select = true doesn't actually select my item (or at least, doesn't highlight it). I'm...
0
1081
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()) { ListViewItem * currentItem = static_cast<ListViewItem*>(itemList->Current); String * tagData = static_cast<String*>(currentItem->Tag); if(verString->Equals(tagData))
3
10377
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 MultiSelect to False. The first click goes as planned, but all subsqequent clicks seem to fire the event twice. The first firing triggers an ArgumentException, resulting in nItem not being initialised. That's why I have the first
3
4877
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 probable internet link. Is there a way to do that? I've looked through the help and can't find anything that, well, helps. Perhaps I'm using the wrong control. Any help would be appreciated. Thanks Steve
6
5025
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 or down the list? Cheers Padu
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.