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. Image for the cookie policy date
close icon

coloring for selectednode at treeviewadv

dear all..

how can i change color of subitem of selectednode?
i'm new on this product...
please advice....


3 Replies

SR SubhaSheela R Syncfusion Team April 11, 2008 06:08 AM UTC

Hi Sherly,

Thank you for using Syncfusion products.

You can handle the TreeViewAdv_MouseDown event to change the color of the selected node. You can get the current mouse position by passing the X and Y axis values to the PointToNode method and change the color of that selected node by using TextColor property of TreeViewAdv. Below is the code snippet:


private void treeViewAdv1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
if (this.treeViewAdv1.PointToNode(new System.Drawing.Point(e.X, e.Y)) == null) return;
this.treeViewAdv1.PointToNode(new System.Drawing.Point(e.X, e.Y)).TextColor = Color.HotPink;
}


Please refer the sample in the below link and let me know if it helps:


http://websamples.syncfusion.com//samples/Tools.Windows/F72757/main.htm


Regards,
Subhasheela R




SN Sherly Numawaty April 11, 2008 07:24 AM UTC

hi...Subhasheela
firstly thank u so much for ur reply

but the things that i want to do is, change color of subitem of selectednode, not the text of selectednode

tx u

sherly




FS Fathima Shalini P Syncfusion Team April 25, 2008 08:22 AM UTC

Hi Sherly,

Thank you for your update.

Please find the code snippets given below for your reference that changes the text color of the subitems of a selected node.


private void treeViewAdv1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
if (this.treeViewAdv1.PointToNode(new System.Drawing.Point(e.X, e.Y)) == null) return;
TreeNodeAdv node = this.treeViewAdv1.PointToNode(new System.Drawing.Point(e.X, e.Y));

if (node.HasChildren)
{
foreach (TreeNodeAdv n in node.Nodes)
{
n.TextColor= Color.Blue;
}
}
}


Please find the simple sample in the following link:

http://websamples.syncfusion.com/samples/Tools.Windows/F72757_1/main.htm

Please let me know if any concerns.

Regards,
Fathima


Loader.
Live Chat Icon For mobile
Up arrow icon