/// <summary> /// When the mouse moves over the list, we change the cursor. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> private void tvLoadout_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { return; } ResultsTreeView.Cursor = ResultsTreeView.GetNodeAt(e.Location)?.Tag != null ? CustomCursors.ContextMenu : Cursors.Default; }
/// <summary> /// Pops up the context menu for the TreeView. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">Arguments of the event.</param> private void tvLoadout_MouseUp(object sender, MouseEventArgs e) { // Show menu only if the right mouse button is clicked if (e.Button != MouseButtons.Right) { return; } ResultsTreeView.Cursor = Cursors.Default; // Get the node that the user has clicked ResultsTreeView.SelectedNode = ResultsTreeView.GetNodeAt(e.Location); // Select the node the user has clicked contextMenu.Show(ResultsTreeView, e.Location); }
/// <summary> /// Pops up the context menu for the TreeView. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">Arguments of the event.</param> private void tvLoadout_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { // Show menu only if the right mouse button is clicked. if (e.Button == MouseButtons.Right) { // Point where the mouse is clicked. Point p = new Point(e.X, e.Y); // Get the node that the user has clicked. TreeNode node = ResultsTreeView.GetNodeAt(p); if (node != null && node.Tag != null) { // Select the node the user has clicked. ResultsTreeView.SelectedNode = node; RightClickContextMenuStrip.Show(ResultsTreeView, p); } } }