<legend id='kWJco'><style id='kWJco'><dir id='kWJco'><q id='kWJco'></q></dir></style></legend>
    <bdo id='kWJco'></bdo><ul id='kWJco'></ul>
  • <tfoot id='kWJco'></tfoot>

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

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

        Windows 窗体中的文本框验证

        Textbox validation in a Windows Form(Windows 窗体中的文本框验证)
          <tbody id='AhtS0'></tbody>

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

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

              • <bdo id='AhtS0'></bdo><ul id='AhtS0'></ul>
                <tfoot id='AhtS0'></tfoot>
                • 本文介绍了Windows 窗体中的文本框验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想验证用户在提交表单之前总是在文本框中输入一个值.但是我所做的检查允许用户输入空格并继续提交表单.那么,如果文本框中只有空格,如何进行检查以使用户无法提交表单.

                  I want to put a validation that the user always enters a value in the textbox before submiting the form. But the check that I have put allows user to enter white spaces and continue submitting the form. So, how to put the check so that the user in not able to submit the form if there are only white spaces in the textbox.

                  推荐答案

                  您可以制作自己的自定义验证函数.这可能很幼稚,但不知何故它会起作用.

                  You can make your own custom validation function. This may be very naive, but somehow it will work.

                  private bool WithErrors()
                  {
                      if(textBox1.Text.Trim() == String.Empty) 
                          return true; // Returns true if no input or only space is found
                      if(textBox2.Text.Trim() == String.Empty)
                          return true;
                      // Other textBoxes.
                  
                      return false;
                  }
                  
                  private void buttonSubmit_Click(object sender, EventArgs e)
                  {
                      if(WithErrors())
                      {
                          // Notify user for error.
                      }
                      else
                      {
                          // Do whatever here... Submit
                      }
                  }
                  

                  这篇关于Windows 窗体中的文本框验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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# 纯数字文本框控件)
                  <tfoot id='NEXyb'></tfoot>
                  • <bdo id='NEXyb'></bdo><ul id='NEXyb'></ul>

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

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

                          <legend id='NEXyb'><style id='NEXyb'><dir id='NEXyb'><q id='NEXyb'></q></dir></style></legend>
                              <tbody id='NEXyb'></tbody>