首页  编辑  

TreeView节点右键菜单效果

Tags: /C#/界面处理/ListView_TreeView/   Date Created:

private bool rightClickNode = false ;

private void contextMenuStrip1_Opening( object sender , CancelEventArgs e)

{

   e . Cancel = ! rightClickNode;

   rightClickNode = false ;

}

private void treeView1_NodeMouseClick( object sender , TreeNodeMouseClickEventArgs e)

{

    if (e . Button == MouseButtons . Right)

   {

       (( TreeView )sender) . SelectedNode = e . Node;

       rightClickNode = true ;

   }

}