|
-
Apr 27th, 2005, 10:07 AM
#1
Thread Starter
Member
Don't turn SelectedListviewItem gray when losing focus
Hi!
If someone is still wondering (and I didn't find one satisfying answer anywhere and setting hideselection=false also didn't work ):
If you don't want your listview to turn the background color of a selected listviewitem to gray when the listview loses focus, then put this into your subclassed listview:
VB Code:
Protected Overrides Sub DefWndProc(ByRef m As System.Windows.Forms.Message)
If Not m.Msg = 8 Then MyBase.DefWndProc(m)
End Sub
As I figure, this traps the message that is responsible for it.
Although I really don't know why it is so difficult to find a list of all the messages (and their relating codes) on the net (and I didn't find that one, too)
Anyhow, that works for me now
Regards!
-
Apr 27th, 2005, 10:33 AM
#2
Re: Don't turn SelectedListviewItem gray when losing focus
wouldn't it be hideselection=true for what you wanted to do?
-
Apr 27th, 2005, 11:43 AM
#3
Re: Don't turn SelectedListviewItem gray when losing focus
Yes, it would work but if you wanted the selection to remain then it wont. Isnt there a Ghosted property that
you can set the color of and maybe duplicate the selected color.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 28th, 2005, 06:01 AM
#4
Thread Starter
Member
Re: Don't turn SelectedListviewItem gray when losing focus
If I turn hideselection=true then the highlighted item turns white when losing focus and you don't see it anymore. When hideselection=false then it just turns to gray.
Also, I didn't find a way to set the background color of a selected item without making item.selected=false because otherwise some mechanism sets the background color of an item to that default selection blue as long as it is selected.
And if I deselect the selected item and then set the background color to another one than the default, the the listviewitems flicker everytime you click on an item.
Wasn't able to handle this, yet...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|