【发布时间】:2014-05-27 16:53:26
【问题描述】:
我正在寻找一种方法来为程序提供导致 ContextMenuStrip 打开的控件。我正在为多个组合框分配相同的条以重复使用它们,就像在课程开始时这样。
myComboBox.ContextMenuStrip = changevaluestrip;
这里我有“添加值”和“删除值”,当然它们中的每一个都必须知道它必须从哪个组合框中删除值。我试着用
private void removeValueToolStrip_Click(object sender, EventArgs e)
{
ToolStripMenuItem usedbox = sender as ToolStripMenuItem;
var parent = usedbox.GetCurrentParent();
DialogResult res = MessageBox.Show("Do you really want to delete this value?", "Delete Value", MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
{
//Delete it from the combobox it was sent from
}
}
但这并没有真正奏效,只是给了我“删除值”作为发件人...
【问题讨论】:
标签: c# combobox contextmenustrip