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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview Node Background

Status
Not open for further replies.

edderic

Programmer
May 8, 1999
628
Hello

Ho can I set alwy's the node backround to gris (if the Node have the Focus then it's Blue) so i want it to Gris !!

tvwDB.Nodes(Current_node).BackColor = &H8000000F

Thanks Eric De Decker
vbg.be@vbgroup.nl

 
Hi,

In the Treeview1_NodeClick event, put the following line

Node.BackColor = vbBlue

You will probably want to put a for each loop to reset all of the others back to the previous back colour before you set the one with focus.

For Each Node in Treeview1.Nodes
Node.BackColor = whatevercolor
Next

Madlarry

 
Correct me if I'm wrong, but I think what Eric was asking was how to change the highlight color of a treeview (that's blue by default) right?

I think you'll need to use some API for that(if it's possible).
Basically the color used for the selected item on a treeview is the one you set on your Windows properties so if you set your system highlight color to gris the highlight color of your selected item on the treeview will also be gris(but also as will everything else on your Windows).

If you don't mind having things like this then your problem is easilly solved.

Otherwise I'm not sure you can set the highlight item color on a treeview without changing sytem's since the treeview control will use system's highlight color. Maybe there is some API that allows you to do this, but I find it dificult...
 
Its oké with next code :

Node_click

If current_node > 0 Then
OldCurrent_node = current_node
End If
current_node = tvwDB.SelectedItem.Index

If OldCurrent_node > 0 Then
tvwDB.Nodes(OldCurrent_node).BackColor = vbWhite
End If
tvwDB.Nodes(current_node).Selected = False
DoEvents
tvwDB.Nodes(current_node).BackColor = &H8000000F

and then on the MouseDown :

tvwDB.SelectedItem.Selected = False

Eric

Eric De Decker
vbg.be@vbgroup.nl

 
you're right Eric it will work with that code, the only thing is that the node you click won't be selected there after, so it can get a liitle bit more tricky to know wich is the current selected node(you'll need to use some variable to store the node index of the node or something).
I think that's a good idea since it simplifys things a bit :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top