开发者

Compatibility of textbox AutoCompleteMode and keyPress event, C#

开发者 https://www.devze.com 2023-01-07 11:50 出处:网络
I have a textbox tbx. For it I had an event handler: publi开发者_运维问答c void tbxPress(object sender, KeyPressEventArgs e)

I have a textbox tbx. For it I had an event handler:

publi开发者_运维问答c void tbxPress(object sender, KeyPressEventArgs e)
    {
        MessageBox.Show("message 1");
        if (e.KeyChar == 13) // i.e. on Enter
        {
            MessageBox.Show("message 2");
        }
    }

and it worked perfect until I set AutoCompleteMode parameter of tbx.

After that auto-complete works fine, but on Enter i don't get "message 2". ... the hell?!

VC#2008EE


You can use the KeyDown event and check e.KeyCode == Keys.Enter.

0

精彩评论

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