1//鼠标右击节点时该节点获得焦点,同时指定TreeList的ContextMenuStrip ;
2private void treelArea_MouseDown(object sender, MouseEventArgs e)
3 {
4 TreeListHitInfo hitInfo = (sender as TreeList).CalcHitInfo(new Point(e.X, e.Y));
5 TreeListNode node = hitInfo.Node;
6
7 if(e.Button==MouseButtons.Right)
8 {
9 if (node!=null)
10 {
11 node.TreeList.FocusedNode = node;
12 node.TreeList.ContextMenuStrip = this.contextMTree;
13 }
14 }
15 }
16
17//右键菜单关闭后设置TreeList的ContextMenuStrip为Null ;
18 private void contextMTree_Closed(object sender, ToolStripDropDownClosedEventArgs e)
19 {
20 this.treelArea.ContextMenuStrip = null;
21 }
2private void treelArea_MouseDown(object sender, MouseEventArgs e)
3 {
4 TreeListHitInfo hitInfo = (sender as TreeList).CalcHitInfo(new Point(e.X, e.Y));
5 TreeListNode node = hitInfo.Node;
6
7 if(e.Button==MouseButtons.Right)
8 {
9 if (node!=null)
10 {
11 node.TreeList.FocusedNode = node;
12 node.TreeList.ContextMenuStrip = this.contextMTree;
13 }
14 }
15 }
16
17//右键菜单关闭后设置TreeList的ContextMenuStrip为Null ;
18 private void contextMTree_Closed(object sender, ToolStripDropDownClosedEventArgs e)
19 {
20 this.treelArea.ContextMenuStrip = null;
21 }