开发者

How can I change the appearance of a Winforms TreeView SelectedNode using C#?

开发者 https://www.devze.com 2023-01-07 02:05 出处:网络
I can set the Treeview selected node using code, but it\'s appearance does not change. TreeNode selectedNode = treeView1.SelectedNode;

I can set the Treeview selected node using code, but it's appearance does not change.

 TreeNode selectedNode = treeView1.SelectedNode;
 TreeNode newNode = new TreeNode("I am new");
 selectedNode.Nodes.Add(newNode);
 treeView1.SelectedNode = newNode;

When I select nodes using my mouse the backgr开发者_如何学Goound color and fore colors change. I want the same thing to happen when I select a node using code. How can I change the appearance of a Winforms TreeView SelectedNode using C#? Thanks!


Did you set HideSelection to false? For some reason the default value is true which will prevent the nodes from appearing selected unless the control has focus (which it of course will have when nodes are seleced using the mouse).

0

精彩评论

暂无评论...
验证码 换一张
取 消