TreeNodeAdv Text Color
3 Replies
DT
Deepa TS
Syncfusion Team
February 20, 2006 10:53 AM UTC
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
ColorOfNode'sText.zip
GR
Gordan Redzic
February 20, 2006 01:41 PM UTC
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
ColorOfNode''sText.zip
DT
Deepa TS
Syncfusion Team
February 21, 2006 05:36 AM UTC
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
GR Gordan Redzic
- Feb 17, 2006 08:39 PM UTC
- Feb 21, 2006 05:36 AM UTC