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

conditionally change nodestyle in treeview

Status
Not open for further replies.

EDB2

MIS
Sep 11, 2002
36
US
Is it possible to change the style (specifically the color) of a single node in a treeview based on a condition?

I have a dynamically built treeview that shows all of the employees who report to a specific manager (as well as all of the employees who report to the managers's employees). The employee has to complete an action, and then the manager completes an action for each employee. I'd like to change the employee name in the treeview from black to green when the employee has completed their action, so the manager can tell at a glance which employees are ready for step 2.

Is this even possible? Everything I've found so far changes the style for the entire tree, rather than for a specific node.
 
If you are building the tree dynamically, then you would change the property of the node before you add it to the parent node.
 
I did take a look at the treenodedatabound event, but there is no property for changing the forecolor. I can change the text or the imageURL, collapse it, expand it, etc - but I don't see a way to change the style of the node?

Same problem with changing the color of the node before you add it - how, exactly, do you do that? The only property I can find that relates to the style of the node is the treeview property 'nodestyle' - but that applies to the entire tree
 
You are correct, there is no property for those things, and you can't add an attribute either. Since you can only add text to a node, you can try something like this:
Code:
Dim textToAdd As String
Dim strHTML As String

textToAdd = "The Name of the Person"
strHTML = "<div style=""color: Green;"">" + textToAdd + "</div>"
Dim newNode As New TreeNode(strHTML)
Me.tv1.Nodes.Add(newNode)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top