troubleshooting Question

TreeView HideSelection False removes highlight

Avatar of DreamU
DreamU asked on
Visual Basic Classic
5 Comments1 Solution3760 ViewsLast Modified:
I have a TreeView control and when the user clicks on a node it highlights fine. When the focus moves away from the control that highlight disappears. So,

categoryTree.HideSelection = False

should fix it, right? No luck, highlight disappears as soon as control loses focus.

So, I decide to set my own background color on the Leave event:

categoryTree.SelectedNode.BackColor = Color.LightBlue
categoryTree.Invalidate()
categoryTree.Refresh()

This does NOT change the node's Backcolor till the control receives the focus again! Huh?

So, I´m thinking maybe there is some system code that executes on the control after my Leave event or the Refresh just doesn´t execute. As a last attempt I put that same code in the next control which receives focus (not a solution just a test). The system still does not repaint the TreeView control with that node´s background color. I've never seen Windows not repaint after the Refresh().

I am striking out 3 for 3 on this feature. I´d try Drawmode = OwnerDrawText but since the control doesn't appear to refresh without the focus I am leery about doing all that extra work for nothing. I am new to using this control - am I just missing something simple?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros