C# Winform 非空驗證


1.遍歷控件方式進行驗證

 1  public bool checkInpu() {
 2  2        foreach (Control item in Controls)//遍歷控件
 3  3        {
 4  4            if (item is TextBox && item.Text == "")//遍歷TextBox類型控件  根據需求可以增加條件跳過某個控件不遍歷
 5  5            {
 6  6                item.Focus();
 7  7                MessageBox.Show("請輸入完善的信息!","信息",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
 8  8                return false;
 9  9            }
10 10             return true;
11 11         }
12    }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM