Hi, I would need to know how to let the programatically selected node make graphically in the state "selected" like the user clicked on it. SelectedNode only makes this one internally selected. Thank you very much!
A:
Not sure, but can you not change the background color of that node?
theraneman
2009-12-03 09:47:10
That would be problematical, I would need to ensure its set back when other node is selected etc.
Petr
2009-12-03 09:55:39
That also seems very hacky.
Pondidum
2009-12-03 09:59:51
A:
The reason it does not show as highlighted is due to the tree view not having focus. This is in a button click event on my test form:
TreeView1.SelectedNode = TreeView1.Nodes(2);
TreeView1.Focus();
Which highlights the node properly. if you remove the Focus();
call it doesn't highlight until you click into the tree view (anywhere in the tree view, not necessarily on to the node that you want to be selected).
Pondidum
2009-12-03 09:59:36
Also the property HideSelection can be used. If set to false the highlight will be shown regardless of focus.
Goran
2009-12-09 20:09:53
A:
The underlying Win32 control supports this (think it's TVIS_DROPHILITED
), but I can't see the same functionality exposed through the TreeView
control.
As theraneman says, you could fake it with the TreeNode.ForeColor
and BackColor
properties...
Tim Robinson
2009-12-03 10:01:57