public void PopUpMenu(int x, int y) { //System.Windows.Forms.Form.ActiveForm //m_menu.Show(m_identifyDlg, new System.Drawing.Point(x,y)); m_menu.Show(m_identifyDlg, m_identifyDlg.PointToClient(new System.Drawing.Point(x, y))); }
private void dataGridView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { int currentMouseOverRow = wgrid.dataGridView1.HitTest(e.X, e.Y).RowIndex; if (currentMouseOverRow >= 0) { wgrid.dataGridView1.Rows[currentMouseOverRow].Selected = true; System.Windows.Forms.DataGridViewRow row = wgrid.dataGridView1.Rows[currentMouseOverRow]; string queueId = row.Cells["TRANS ID"].Value.ToString(); wgrid.dataGridView1.Focus(); System.Windows.Forms.MenuItem men = new System.Windows.Forms.MenuItem(queueId); men.Enabled = false; System.Windows.Forms.MenuItem menuItemHold = new System.Windows.Forms.MenuItem("Hold"); menuItemHold.Click += menuItem_Click; menuItemHold.Tag = row; System.Windows.Forms.MenuItem menuItemResume = new System.Windows.Forms.MenuItem("Resume"); menuItemResume.Click += menuItem_Click; menuItemResume.Tag = row; m.MenuItems.Clear(); m.MenuItems.Add(men); m.MenuItems.Add(menuItemHold); m.MenuItems.Add(menuItemResume); m.Show(wgrid.dataGridView1, new System.Drawing.Point(e.X, e.Y)); } } }
void dataGridView1_CellMouseClick(object sender, System.Windows.Forms.DataGridViewCellMouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (e.ColumnIndex == dataGridView1.Columns["Status"].Index) { try { var menuItems = new System.Collections.Generic.List <string>() { "Принят", "Склад", "Продан", "Удалить" }; var menu = new System.Windows.Forms.ContextMenu(); menuItems.Remove(dataGridView1["Status", e.RowIndex].Value.ToString()); foreach (var m in menuItems) { menu.MenuItems.Add(m, new System.EventHandler(menuClick)); } ; dataGridView1.Rows[e.RowIndex].Selected = true; menu.Show(dataGridView1, new System.Drawing.Point(e.Location.X + 200, e.Location.Y)); } catch { } } } }
public void ShowContextMenu(System.Windows.Forms.ContextMenu menu) { if (panel_winforms == null) { return; } menu.Show(panel_winforms, new System.Drawing.Point(0, 0)); }
void MyRootControl_ShouldShowPopupMenu(ICommandList menu, System.Drawing.Point location) { #if UseOldContextMenu strip.MenuItems.Clear(); #else strip.Items.Clear(); #endif foreach (ICommand item in menu) { #if UseOldContextMenu OldStyleMenuCommand i = new OldStyleMenuCommand(item); strip.MenuItems.Add(i); #else MenuCommand i = new MenuCommand(item); strip.Items.Add(i); #endif } location.X += -MainShape.Scrollable.DeltaX; location.Y += -MainShape.Scrollable.DeltaY; strip.Show(this, location); }