<bdo id='0KEST'></bdo><ul id='0KEST'></ul>
  • <small id='0KEST'></small><noframes id='0KEST'>

    <tfoot id='0KEST'></tfoot>
  • <i id='0KEST'><tr id='0KEST'><dt id='0KEST'><q id='0KEST'><span id='0KEST'><b id='0KEST'><form id='0KEST'><ins id='0KEST'></ins><ul id='0KEST'></ul><sub id='0KEST'></sub></form><legend id='0KEST'></legend><bdo id='0KEST'><pre id='0KEST'><center id='0KEST'></center></pre></bdo></b><th id='0KEST'></th></span></q></dt></tr></i><div id='0KEST'><tfoot id='0KEST'></tfoot><dl id='0KEST'><fieldset id='0KEST'></fieldset></dl></div>

        <legend id='0KEST'><style id='0KEST'><dir id='0KEST'><q id='0KEST'></q></dir></style></legend>

        在文本框中捕获 Ctrl + C

        时间:2023-06-09
        1. <legend id='mNLMw'><style id='mNLMw'><dir id='mNLMw'><q id='mNLMw'></q></dir></style></legend>

          <i id='mNLMw'><tr id='mNLMw'><dt id='mNLMw'><q id='mNLMw'><span id='mNLMw'><b id='mNLMw'><form id='mNLMw'><ins id='mNLMw'></ins><ul id='mNLMw'></ul><sub id='mNLMw'></sub></form><legend id='mNLMw'></legend><bdo id='mNLMw'><pre id='mNLMw'><center id='mNLMw'></center></pre></bdo></b><th id='mNLMw'></th></span></q></dt></tr></i><div id='mNLMw'><tfoot id='mNLMw'></tfoot><dl id='mNLMw'><fieldset id='mNLMw'></fieldset></dl></div>
          <tfoot id='mNLMw'></tfoot>
            <tbody id='mNLMw'></tbody>
        2. <small id='mNLMw'></small><noframes id='mNLMw'>

              • <bdo id='mNLMw'></bdo><ul id='mNLMw'></ul>

                  本文介绍了在文本框中捕获 Ctrl + C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  尽管我多年来一直使用 C#(Windows 窗体),但我还是有头脑失败的时刻,我一生都无法弄清楚如何捕捉用户在文本框中输入 Ctrl + C.

                  Despite me working with C# (Windows Forms) for years, I'm having a brain fail moment, and can't for the life of me figure out how to catch a user typing Ctrl + C into a textbox.

                  我的应用程序基本上是一个终端应用程序,我希望 Ctrl + C 发送一个 (byte)3 到串口,而不是复制到剪贴板的快捷方式.

                  My application is basically a terminal application, and I want Ctrl + C to send a (byte)3 to a serial port, rather than be the shortcut for Copy to Clipboard.

                  我已在文本框上将快捷方式 enabled 属性设置为 false.然而,当用户点击 Ctrl + C 时,keypress 事件不会触发.

                  I've set the shortcuts enabled property to false on the textbox. Yet when the user hits Ctrl + C, the keypress event doesn't fire.

                  如果我捕捉到 keydown,则当用户按下 Ctrl 时(即在他们按下 C 键之前)触发该事件.

                  If I catch keydown, the event fires when the user presses Ctrl (that is, before they hit the C key).

                  这可能是我想念的简单得愚蠢的东西.

                  It's probably something stupidly simple that I'm missing.

                  推荐答案

                  继续使用 KeyDown 事件,但在该事件中检查 both CtrlC,像这样:

                  Go ahead and use the KeyDown event, but in that event check for both Ctrl and C, like so:

                  if (e.Control && e.KeyCode == Keys.C) {
                      //...
                      e.SuppressKeyPress = true;
                  }
                  

                  此外,为防止底层 TextBox 处理击键,请将 SuppressKeyPress 属性设置为 true,如图所示.

                  Also, to prevent processing the keystroke by the underlying TextBox, set the SuppressKeyPress property to true as shown.

                  这篇关于在文本框中捕获 Ctrl + C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何选择 Windows 窗体文本框中的所有文本? 下一篇:如何为多行文本框设置最大长度?

                  相关文章

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

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

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