Hi everyone, I have a treeview and I want to highlight (change the text color) of a node in the treeview once that node has been selected. This isnt working for me for some reason. when I select a node nothing happens, but when I click the plus on the same node I just selected...it highlights...and even then when I click any of the childnodes, nothing happens and the root node stays highlighted always. Can anyone point me in the right direction...I'm using c#.
A:
The following works for me. Please note that I cancel the actual selection though, since otherwise the selection highlight would hide my highlightning. So you might have to keep track of which node is selected manually.
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
Dehighlight(treeView1.Nodes);
e.Node.ForeColor = Color.Red;
e.Cancel = true;
}
private void Dehighlight(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
node.BackColor = Color.White;
node.ForeColor = Color.Black;
Dehighlight(node.Nodes);
}
}
ho1
2010-04-30 21:14:08
thanks for the insight ho...lol but it was stupid navigateURL not working with SelectedNodeChanged...
DrybLrac
2010-05-06 14:49:52