简体   繁体   English

ContextMenuStrip不会失去焦点

[英]ContextMenuStrip without stealing focus

Do you have any idea how to show ContextMenuStrip without stealing focus to current control? 您是否知道如何显示ContextMenuStrip而不将焦点转移到当前控件上? I would like to do sort of autocomplete with TextBox and ContextMenuStrip below it as list of options to choose. 我想使用它下面的TextBox和ContextMenuStrip进行自动完成,作为选择选项的列表。 But whenever I show ContextMenuStrip it steals focus from textbox so I cannot catch Text_Changed again... I want to use ContextMenuStrip because I want to use pictures, or other other controls in list of given items. 但是每当我显示ContextMenuStrip时,它都会从文本框中夺取焦点,因此我无法再次捕获Text_Changed ...我想使用ContextMenuStrip,因为我想使用图片或给定项目列表中的其他控件。

Thanks 谢谢

Not sure what you mean by 'cannot catch Text_Changed' again ? 不知道“无法再捕获Text_Changed”是什么意思? I would imagine something like this should work : 我想像这样的事情应该工作:

// event registered to text box's text changed event
private void HandlerForTextChanged() 
{
  // Get The Current Text So Far Filled In
  // Process and Show Contextmenu strip
  // Reset the focus back to text box (textbox1.SetFocus()) 
}

Also, can also think of re-designig the control as one composite control. 同样,也可以将控件重新设计为一个复合控件。

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

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