Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I find the color for a "selected item" from system colors?

Status
Not open for further replies.

NoCoolHandle

Programmer
Apr 10, 2003
2,321
0
0
US
Ok.. I am getting closer to an answer my treeview question.

There doesn't seem to be any easy way to leave it in the same state as when you "click" an item in the treeview. So. it seems that the answer is to change the back color of it, as well as the one that had previously been selected.

So.. for the sake of consistancy, I thought it would be nice to set the color to the system color that = a selected item. Like the color you get when you "select text in a textbox"..

However I am having the devils time finding the correct "system color".

To date the closest would be to set the backcolor to

Color.FromKnownColor(KnownColor.Highlight)

but it isn't quite right. Any ideas?

TIA

Rob
PS Happy Holidays all! (what ever your holiday is)
 
I hate it when I find the answer

(the color was rigth for the back color, but I had forgotten to change the forcolor to white, so it didn't look right)

So.. the correct lines are.
Code:
            tvMenu.SelectedNode = n.Parent.Nodes(n.Index - 1)
            tvMenu.SelectedNode.BackColor = Color.FromKnownColor(KnownColor.Highlight)
            tvMenu.SelectedNode.ForeColor = Color.White
            tvMenu.SelectedNode.Parent.Nodes(tvMenu.SelectedNode.Index + 1).BackColor = Color.White
            tvMenu.SelectedNode.Parent.Nodes(tvMenu.SelectedNode.Index + 1).ForeColor = Color.Black

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top