Beispiel #1
0
        /// <summary>
        /// Detects if a TreeNode is right clicked and then displays a menu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FolderTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                selectedTreeNode = FolderTreeView.GetNodeAt(e.X, e.Y);

                ContextMenuStrip  mnu         = new ContextMenuStrip();
                ToolStripMenuItem mnuGenerate = new ToolStripMenuItem("Generate Report");

                //Assign event handlers
                mnuGenerate.Click += new EventHandler(mnuGenerate_Click);

                //Add to main context menu
                mnu.Items.AddRange(new ToolStripItem[] { mnuGenerate });
                //Assign to datagridview
                //FolderTreeView.Nodes[0].ContextMenuStrip = mnu;

                selectedTreeNode.ContextMenuStrip = mnu;
            }
        }