/// <summary> /// listBox右键菜单 /// </summary> private void RuleListBox_MouseUp(object sender, MouseEventArgs e) { RuleListBox.SelectedIndex = RuleListBox.IndexFromPoint(e.X, e.Y); if (RuleListBox.SelectedIndex == -1) { return; } if (e.Button == MouseButtons.Right) { contextMenuStrip.Show(RuleListBox, e.Location); } }
/// <summary> /// listBox右键菜单 /// </summary> private void RuleListBox_MouseUp(object sender, MouseEventArgs e) { RuleListBox.SelectedIndex = RuleListBox.IndexFromPoint(e.X, e.Y); if (RuleListBox.SelectedIndex == -1) { return; } if (e.Button == MouseButtons.Right) { var strip = new ContextMenuStrip(); strip.Items.Add(i18N.Translate("Delete")); strip.Items[0].Click += deleteRule_Click; strip.Show(RuleListBox, e.Location); //鼠标右键按下弹出菜单 } }