コード例 #1
0
        /// <summary>
        /// If the action was a right-click find the node that was at the right-click position and pass it along
        /// with the custom TreeRightClick event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //Handles TreeView1.MouseDown
        public void TreeView1MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                // get the treenode at the mouse location
                TreeNode t = TreeView1.GetNodeAt(e.X, e.Y);

                // only proceed if there was a valid clicked node
                if (t == null)
                {
                    return;
                }

                TreeView1.SelectedNode = t;

                if (TreeRightClick != null)
                {
                    TreeRightClick(sender, e, t);
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Gets the TreeNode at position x, y.
 /// </summary>
 public System.Windows.Forms.TreeNode GetNodeAt(int x, int y)
 {
     return(TreeView1.GetNodeAt(x, y));
 }