ToolStripCombobox displays at the top left corner of the screen when DropDownStyle is Simple

僤鯓⒐⒋嵵緔 提交于 2019-12-02 10:40:24

To solve the problem put this code in the Load event of form:

var item = toolStripComboBox1;
var createControl = item.Control.Parent.GetType().GetMethod("CreateControl",
    System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
createControl.Invoke(item.Control.Parent, new object[] { true });

It's a strange bug and I don't have any idea why the ToolStripComboBox with DisplayStyle set to Simple suffers from this bug but by setting DisplayStyle to DropDown or DropDownList doesn't have this bug.

Using above code, I forced the owner ToolStripDropDownMenu be created before being shown.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!