0

我有一个树节点,如下所述动态创建: ->UK,->India ->Delhi ->Mumbai ->USA ->Russia 单击节点时需要更改节点的颜色。至于例如如果我点击德里德里应该突出显示,如果俄罗斯然后俄罗斯。等等当我点击节点时我调用相同的

4

1 回答 1

0

You can use NodeMouseClick event to set the background color of the selected Node.

Define a class level TreeNode member

TreeNode node = null;

And use the logic given below,

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
    if (null != node)
     {
         //Reset the color when selected node changes
         node.BackColor = Color.White;
     }

     //Set the currently selected node color
     e.Node.BackColor = Color.Green;

     node = e.Node;
 }
于 2013-09-13T06:49:56.877 回答