我有一个 ToolStripMenuItem,其中包含可供选择的子菜单。问题是它们显示在错误的位置:
我有这段代码用于上述项目的子菜单(这是用于 ToolStripCombobox - 谢谢Reza的解决方案 - ),但我很难调整以使其适用于 ToolStripMenuItem,因为它没有包含一个 Control.Parent.GetType() :
private void Form_Load(object sender, EventArgs e)
{
var item = toolStripComboBox;
var createControl = item.Control.Parent.GetType().GetMethod("CreateControl",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
createControl.Invoke(item.Control.Parent, new object[] { true });
一如既往,任何帮助表示赞赏。