简体   繁体   English

如何防止菜单(ContextMenuStrip)窃取我的TextBox控件的焦点?

[英]How to prevent menu (ContextMenuStrip) to steal focus from my TextBox control?

I am trying to replicate an intellisense like feature where you have a textbox and a menu that's shown below it. 我正在尝试复制一个类似intellisense的功能,其中您有一个文本框和一个显示在它下面的菜单。 I know intellisense doesn't use ContextMenuStrip, but my version has to have categories which are sub-menu items. 我知道intellisense不使用ContextMenuStrip,但是我的版本必须具有属于子菜单项的类别。

So as soon as the user clicks into my TextBox, I bring up the menu below once, but then even though I can see the caret in my TextBox it doesn't receive any key inputs. 因此,一旦用户单击我的TextBox,我就会调出下面的菜单一次,但是即使我可以在TextBox中看到插入符号,也不会收到任何关键输入。 I have to click inside the TextBox again but that removes the menu from the screen. 我必须再次在TextBox内单击,但这会从屏幕上删除菜单。

Is there a way to prevent this? 有办法防止这种情况吗? Or perhaps make the menu persistent on the screen without stealing focus? 还是使菜单持久显示在屏幕上而不会失去焦点?

带有添加项的ToolStrip控件似乎可以正常运行,因为它始终在窗体上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM