Vandana
Vandana

Reputation: 79

How to highlight Tree path of selected node in TreeView control?

I want to highlight TreePath till root node of the selected Node.

 protected void Trv_SelectedNodeChanged(object sender, EventArgs e)
        {
            HighlightPath(Trv.SelectedNode);
        }
 private void HighlightPath(TreeNode node)
        {
           //  node.["style"] = "color: orange";
            if (node.Parent != null)
            HighlightPath(node.Parent);

        }

How Can I highLight path or change parent node color till root level? Please help on this

Upvotes: 0

Views: 2005

Answers (2)

Amul Harad
Amul Harad

Reputation: 146

Use

node.addcss["forecolor"]="color:orange";

Upvotes: 0

pravprab
pravprab

Reputation: 2293

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
    HighlightPath(TreeView1.SelectedNode);
}
private void HighlightPath(TreeNode node)
{
    //  node.["style"] = "color: orange";
    node.SelectAction = TreeNodeSelectAction.None;
    node.Text = "<div style='color:orange'>" + node.Text + "</div>";
    if (node.Parent != null)
        HighlightPath(node.Parent);

}

Upvotes: 1

Related Questions