开发者

onKeyPress event do not work if a textbox in form has autocomplete?

I have a form with keypreview true. OnKeyPress (if key is escape) I was closing the form.

Later I set autocomplete with the first text box in form. Autocomplete is working but OnKeyPress event is not working now. If cursor is not in text box having auto-complete OnKeyPress works and still close the form on escape key.

Please guide how I开发者_如何学Python can have both ? Autocomplete with closing form on escape.


In your application you should not use form events for closing (because any control on your form can handle OnKeyPress by it's own and swallow it), you should register the hotkey.

[DllImport("user32.dll")]
private static extern bool RegisterHotKey (int hwnd, int id, int fsModifiers, int vk);

[DllImport("user32.dll")]
private static extern bool UnregisterHotKey (int hwnd, int id);

Refer to here or to here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜