• <small id='Ds3ZG'></small><noframes id='Ds3ZG'>

    1. <legend id='Ds3ZG'><style id='Ds3ZG'><dir id='Ds3ZG'><q id='Ds3ZG'></q></dir></style></legend>
        <bdo id='Ds3ZG'></bdo><ul id='Ds3ZG'></ul>
      <i id='Ds3ZG'><tr id='Ds3ZG'><dt id='Ds3ZG'><q id='Ds3ZG'><span id='Ds3ZG'><b id='Ds3ZG'><form id='Ds3ZG'><ins id='Ds3ZG'></ins><ul id='Ds3ZG'></ul><sub id='Ds3ZG'></sub></form><legend id='Ds3ZG'></legend><bdo id='Ds3ZG'><pre id='Ds3ZG'><center id='Ds3ZG'></center></pre></bdo></b><th id='Ds3ZG'></th></span></q></dt></tr></i><div id='Ds3ZG'><tfoot id='Ds3ZG'></tfoot><dl id='Ds3ZG'><fieldset id='Ds3ZG'></fieldset></dl></div>

    2. <tfoot id='Ds3ZG'></tfoot>

      1. 从自动完成建议列表中选择一个项目会引发带有 ENTER 键的 KeyDown-event

        Selecting an item from AutoComplete suggestion list raises KeyDown-event with ENTER key(从自动完成建议列表中选择一个项目会引发带有 ENTER 键的 KeyDown-event)
          <tbody id='dLidn'></tbody>

        <i id='dLidn'><tr id='dLidn'><dt id='dLidn'><q id='dLidn'><span id='dLidn'><b id='dLidn'><form id='dLidn'><ins id='dLidn'></ins><ul id='dLidn'></ul><sub id='dLidn'></sub></form><legend id='dLidn'></legend><bdo id='dLidn'><pre id='dLidn'><center id='dLidn'></center></pre></bdo></b><th id='dLidn'></th></span></q></dt></tr></i><div id='dLidn'><tfoot id='dLidn'></tfoot><dl id='dLidn'><fieldset id='dLidn'></fieldset></dl></div>
        <tfoot id='dLidn'></tfoot>
      2. <legend id='dLidn'><style id='dLidn'><dir id='dLidn'><q id='dLidn'></q></dir></style></legend>

          <bdo id='dLidn'></bdo><ul id='dLidn'></ul>

                  <small id='dLidn'></small><noframes id='dLidn'>

                  本文介绍了从自动完成建议列表中选择一个项目会引发带有 ENTER 键的 KeyDown-event的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Winforms 中,我有一个 AutoCompleteMode 设置为 SuggestAppend 和一个 AutoCompleteCustomSource 设置的文本框.当用户键入一些字母时,会显示建议列表.如果通过鼠标单击选择了此列表中的某个项目,则会针对 ENTER 键引发包含文本框的表单的 KeyDown 事件.

                  In Winforms I have a textbox with AutoCompleteMode set to SuggestAppend and a AutoCompleteCustomSource set. When the user types some letters the suggestion list is shown. If an item of this list is selected by clicking it with the mouse, the KeyDown-event of the form containing the textbox is raised for the ENTER key.

                  用鼠标选择建议的项目时是否有可能不引发此事件?

                  Is there any possibility to NOT raise this event when selecting a suggested item with the mouse?

                  推荐答案

                  自动完成功能有几个怪癖,这些怪癖继承自其最初的设计用途,即 Internet Explorer 的地址框.这包括在您单击列表中的项目时发出 Enter 键.在 IE 的地址框中按 Enter 键会导航到输入的 URL.

                  The AutoComplete feature has a couple of quirks that were inherited from its original designed use, the address box of Internet Explorer. This includes emitting the Enter key when you click on an item in the list. Pressing Enter in the address box of IE makes it navigate to the entered URL.

                  对此您无能为力,本机界面 (IAutoComplete2) 几乎没有用于配置其工作方式的选项.它通过伪造 Windows 消息将击键插入文本框.这是您可以区分的一种方法,实际的密钥不会被关闭.您可以通过调用 GetKeyState() 进行检查,如下所示:

                  There isn't anything you can do about that, the native interface (IAutoComplete2) has very few options to configure the way it works. It pokes the keystrokes into the text box by faking Windows messages. Which is one way you can tell the difference, the actual key won't be down. Something you can check by pinvoking GetKeyState(), like this:

                      private void textBox1_KeyDown(object sender, KeyEventArgs e) {
                          if (e.KeyData == Keys.Enter && GetKeyState(Keys.Enter) < 0) {
                              Console.WriteLine("Really down");
                          }
                      }
                  
                      [System.Runtime.InteropServices.DllImport("user32.dll")]
                      private static extern short GetKeyState(Keys key);
                  

                  这篇关于从自动完成建议列表中选择一个项目会引发带有 ENTER 键的 KeyDown-event的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                  Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                  C# - Add button click events using code(C# - 使用代码添加按钮单击事件)
                  Multi-color TextBox C#(多色文本框 C#)
                  How can i set the caret position to a specific index in passwordbox in WPF(如何将插入符号位置设置为 WPF 密码框中的特定索引)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                  <i id='Hxbji'><tr id='Hxbji'><dt id='Hxbji'><q id='Hxbji'><span id='Hxbji'><b id='Hxbji'><form id='Hxbji'><ins id='Hxbji'></ins><ul id='Hxbji'></ul><sub id='Hxbji'></sub></form><legend id='Hxbji'></legend><bdo id='Hxbji'><pre id='Hxbji'><center id='Hxbji'></center></pre></bdo></b><th id='Hxbji'></th></span></q></dt></tr></i><div id='Hxbji'><tfoot id='Hxbji'></tfoot><dl id='Hxbji'><fieldset id='Hxbji'></fieldset></dl></div>
                  <tfoot id='Hxbji'></tfoot>

                          <bdo id='Hxbji'></bdo><ul id='Hxbji'></ul>

                            <tbody id='Hxbji'></tbody>

                          <small id='Hxbji'></small><noframes id='Hxbji'>

                        • <legend id='Hxbji'><style id='Hxbji'><dir id='Hxbji'><q id='Hxbji'></q></dir></style></legend>