473,695 Members | 3,385 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 4254
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
1640
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
1873
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
2402
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
5601
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
3702
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
1075
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
10364
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
4874
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
5021
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
8582
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,...
1
8860
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,...
0
8832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7672
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4348
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
4587
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3018
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2281
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1984
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.