/// <summary> /// 鼠标动作(非顶层) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void trvData_MouseClick_NotTop(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { contextMenuStripMain = new ContextMenuStrip(); contextMenuStripMain.Items.Add(AddElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(ModifyElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(DropElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(CopyElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(CutElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(PasteElementToolStripMenuItem.Clone()); trvData.DatatreeView.ContextMenuStrip = contextMenuStripMain; contextMenuStripMain.Show(trvData.DatatreeView.PointToScreen(e.Location)); } }
/// <summary> /// 鼠标动作(非顶层) /// </summary> /// <param name="e"></param> private void trvData_MouseClick_NotTop(MouseEventArgs e) { if (MDataViewInfo.IsView) { return; //View是只读的 } if (e.Button != MouseButtons.Right) { return; } contextMenuStripMain = new ContextMenuStrip(); contextMenuStripMain.Items.Add(AddElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(ModifyElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(DropElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(CopyElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(CutElementToolStripMenuItem.Clone()); contextMenuStripMain.Items.Add(PasteElementToolStripMenuItem.Clone()); trvData.DatatreeView.ContextMenuStrip = contextMenuStripMain; contextMenuStripMain.Show(trvData.DatatreeView.PointToScreen(e.Location)); }