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

      1. <small id='dM3BA'></small><noframes id='dM3BA'>

      2. 如何禁用文本框中的光标?

        时间:2023-06-10

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

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

                1. <legend id='pz9zN'><style id='pz9zN'><dir id='pz9zN'><q id='pz9zN'></q></dir></style></legend>

                2. 本文介绍了如何禁用文本框中的光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法在不将属性 Enable 设置为 false 的情况下禁用文本框中的光标?我试图使用 ReadOnly 属性,但尽管我无法在文本框中写入,但如果我单击文本框,则会出现光标.那么有什么办法可以永久去掉这个光标呢?

                  Is there any way to disable cursor in textbox without setting property Enable to false? I was trying to use ReadOnly property but despite the fact that I can't write in textbox, the cursor appears if I click the textbox. So is there any way to get rid of this cursor permamently?

                  推荐答案

                  在 C# 中,您可以使用以下只读文本框:

                  In C#, you can use the following read-only textbox:

                  public class ReadOnlyTextBox : TextBox
                  {
                      [DllImport("user32.dll")]
                      static extern bool HideCaret(IntPtr hWnd);
                  
                      public ReadOnlyTextBox()
                      {
                          this.ReadOnly = true;
                          this.BackColor = Color.White;
                          this.GotFocus += TextBoxGotFocus;
                          this.Cursor = Cursors.Arrow; // mouse cursor like in other controls
                      }
                  
                      private void TextBoxGotFocus(object sender, EventArgs args)
                      {
                          HideCaret(this.Handle);
                      }
                  }
                  

                  这篇关于如何禁用文本框中的光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:多行文本框多个换行符 下一篇:WPF:从 WPF 文本框派生的控件中没有为空格键调用 OnKeyDown()

                  相关文章

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

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

                      <tfoot id='J5EmV'></tfoot>
                      <legend id='J5EmV'><style id='J5EmV'><dir id='J5EmV'><q id='J5EmV'></q></dir></style></legend>