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

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

        更改文本框的边框颜色

        Change the borderColor of the TextBox(更改文本框的边框颜色)

          <small id='7OjBr'></small><noframes id='7OjBr'>

            1. <legend id='7OjBr'><style id='7OjBr'><dir id='7OjBr'><q id='7OjBr'></q></dir></style></legend>
              • <tfoot id='7OjBr'></tfoot>
                  <bdo id='7OjBr'></bdo><ul id='7OjBr'></ul>

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

                  本文介绍了更改文本框的边框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当用户点击或关注文本框时,如何更改文本框的边框颜色?

                  How can I change the BorderColor of the Textbox when a user Clicks on it or focuses on it?

                  推荐答案

                  试试这个

                  bool focus = false;
                  private void Form1_Paint(object sender, PaintEventArgs e)
                  {
                      if (focus)
                      {
                          textBox1.BorderStyle = BorderStyle.None;
                          Pen p = new Pen(Color.Red);
                          Graphics g = e.Graphics;
                          int variance = 3;
                          g.DrawRectangle(p, new Rectangle(textBox1.Location.X - variance, textBox1.Location.Y - variance, textBox1.Width + variance, textBox1.Height +variance ));
                      }
                      else
                      {
                          textBox1.BorderStyle = BorderStyle.FixedSingle;
                      }
                  }
                  
                  private void textBox1_Enter(object sender, EventArgs e)
                  {
                      focus = true;
                      this.Refresh();
                  }
                  
                  private void textBox1_Leave(object sender, EventArgs e)
                  {
                      focus = false;
                      this.Refresh();
                  }
                  

                  这篇关于更改文本框的边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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# 纯数字文本框控件)

                      <tbody id='3vnyk'></tbody>
                      • <bdo id='3vnyk'></bdo><ul id='3vnyk'></ul>

                          <small id='3vnyk'></small><noframes id='3vnyk'>

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

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