We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

TreeNodeAdv Text Color

Thread ID:

Created:

Updated:

Platform:

Replies:

40974 Feb 17,2006 03:39 PM Feb 21,2006 12:36 AM Windows Forms 3
loading
Tags: Tools
Gordan Redzic
Asked On February 17, 2006 03:39 PM

How can I programatically change the color of a single node''s text?

Deepa TS [Syncfusion]
Replied On February 20, 2006 05:53 AM

Hi Rich, You could programatically change the color of a single node''s text by handling treeViewAdv1_BeforeNodePaint Event along with setting OwnerDrawNodes property to true . Coding: this.treeViewAdv1.OwnerDrawNodes = true; private void treeViewAdv1_BeforeNodePaint(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvPaintEventArgs e) { if(e.Node.Text.ToString()=="Node0") { e.Node.TextColor=Color.Red; } if(e.Node.Text.ToString()=="Node1") { e.Node.TextColor=Color.Blue; } else if(e.Node.Text.ToString()=="Node2") { e.Node.TextColor=Color.GreenYellow; } else if(e.Node.Text.ToString()=="Node3") { e.Node.TextColor=Color.Aqua; } else if(e.Node.Text.ToString()=="Node4") { e.Node.TextColor=Color.Violet; } else if(e.Node.Text.ToString()=="Node5") { e.Node.TextColor=Color.Chocolate; } } Please take a look at the attached sample and let me know if this helps you. Thanks for your continued interest in Syncfusion products. Regards, Deepa.T.S

ColorOfNode'sText.zip

Gordan Redzic
Replied On February 20, 2006 08:41 AM

Hi Deepa, This definitely works but there seems to be several "side effects" that are not desireable. It seems that the BeforeNodePaint event is being called over and over when the tree is in the current view. Also, a node''s helptext is not being shown when it is set (verified text was not empty in debugger). Is there no way to change a node''s text''s color when I create the tree without using the BeforeNodePaint event? Thanks, Rich >Hi Rich, > >You could programatically change the color of a single node''s text by handling treeViewAdv1_BeforeNodePaint Event along with setting OwnerDrawNodes property to true . > >Coding: > >this.treeViewAdv1.OwnerDrawNodes = true; > >private void treeViewAdv1_BeforeNodePaint(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvPaintEventArgs e) >{ >if(e.Node.Text.ToString()=="Node0") >{ >e.Node.TextColor=Color.Red; >} >if(e.Node.Text.ToString()=="Node1") >{ >e.Node.TextColor=Color.Blue; >} >else if(e.Node.Text.ToString()=="Node2") >{ >e.Node.TextColor=Color.GreenYellow; >} >else if(e.Node.Text.ToString()=="Node3") >{ >e.Node.TextColor=Color.Aqua; >} >else if(e.Node.Text.ToString()=="Node4") >{ >e.Node.TextColor=Color.Violet; >} >else if(e.Node.Text.ToString()=="Node5") >{ >e.Node.TextColor=Color.Chocolate; >} >} > >Please take a look at the attached sample and let me know if this helps you. > >Thanks for your continued interest in Syncfusion products. > >Regards, > >Deepa.T.S >

ColorOfNode''sText.zip

Deepa TS [Syncfusion]
Replied On February 21, 2006 12:36 AM

Hi Rich, Sorry for the inconvenience caused. Please take a look at the attached sample to change the node''s TextColor without using BeforeNodePaint event. NodeColor Please let me know if this helps you. Thanks for your continued interest in Syncfusion Products. Regards, Deepa.T.S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;