欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

C#中怎么實(shí)現(xiàn)一個(gè)TextBox事件

本篇文章為大家展示了C# 中怎么實(shí)現(xiàn)一個(gè)TextBox事件,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

公司主營(yíng)業(yè)務(wù):網(wǎng)站制作、成都網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。創(chuàng)新互聯(lián)推出忠縣免費(fèi)做網(wǎng)站回饋大家。

C# TextBox事件具體的需求:

◆界面要求:定義5個(gè)TEXTBOX,分別是:姓名、地址、職業(yè)、年齡、輸出內(nèi)容。1個(gè)BUTTON

◆滿足條件:

(1)用戶名不能為空

(2)年齡必須是一個(gè)大于或等于0的數(shù)字

(3)職業(yè)必須是“程序員”或?yàn)榭?/p>

(4)地址不能為空

C# TextBox事件實(shí)例實(shí)現(xiàn):

using System;  using System.Collections.Generic;  using System.ComponentModel;  using System.Data;  using System.Drawing;  using System.Text;  using System.Windows.Forms;  namespace Chapter14  ...{  public partial class Form1 : Form  ...{  public Form1()  ...{  InitializeComponent();  this.button1.Enabled = false;  this.textBox1.Tag = false;  this.textBox2.Tag = false;  this.textBox3.Tag = false;  this.textBox4.Tag = false;  this.textBox1.Validating+=   new System.ComponentModel.CancelEventHandler(  this.textboxEmpty_Validating);  this.textBox2.Validating +=   new System.ComponentModel.CancelEventHandler(  this.textboxEmpty_Validating);  this.textBox3.Validating+=   new System.ComponentModel.CancelEventHandler(  this.textboxOccupation_Validating);  this.textBox4.Validating +=   new System.ComponentModel.CancelEventHandler(  this.textboxEmpty_Validating);  this.textBox1.TextChanged +=   new System.EventHandler(this.textbox_TextChanged);  this.textBox4.TextChanged +=   new System.EventHandler(this.textbox_TextChanged);  this.textBox3.TextChanged +=   new System.EventHandler(this.textbox_TextChanged);  }  //C# TextBox事件  private void textboxOccupation_Validating(  object sender,   System.ComponentModel.CancelEventArgs e)  ...{  TextBox tb=(TextBox)sender;  if (tb.Text.CompareTo("Programmer") == 0||tb.Text.Length==0)  ...{  tb.Tag = true;  tb.BackColor = System.Drawing.SystemColors.Window;    }  else ...{  tb.Tag = false;  tb.BackColor = Color.Red;   }  ValidateOk();  }  //C# TextBox事件  private void textboxEmpty_Validating(  object sender,   System.ComponentModel.CancelEventArgs e)  ...{  TextBox tb = (TextBox)sender;  if (tb.Text.Length == 0)  ...{  tb.BackColor = Color.Red;  tb.Tag = false;  }  else ...{  tb.BackColor = System.Drawing.SystemColors.Window;  tb.Tag = true;  }  ValidateOk();  }  private void textboxAge_KeyPress(  object sender, KeyPressEventArgs e)  ...{  if ((e.KeyChar < 48 || e.KeyChar > 57) &&   e.KeyChar != 8)  e.Handled = true;  }  private void textbox_TextChanged(  object sender, System.EventArgs e)  ...{  TextBox tb = (TextBox)sender;  if (tb.Text.Length == 0&& tb!=textBox3)  ...{  tb.Tag = false;  tb.BackColor = Color.Red;   }  else if (tb == this.textBox3 &&   (tb.Text.Length != 0 &&   tb.Text.CompareTo("Programmer") != 0))  ...{  tb.Tag = false;  }  //C# TextBox事件  else ...{  tb.Tag = true;  tb.BackColor = SystemColors.Window;  }  ValidateOk();  }  private void ValidateOk()  ...{  this.button1.Enabled =   ((bool)(this.textBox2.Tag) &&   (bool)(this.textBox4.Tag) &&   (bool)(this.textBox1.Tag) &&   (bool)(this.textBox3.Tag));  }   private void button1_Click(  object sender, EventArgs e)  ...{  string output;    //C# TextBox事件  output = "Name:" + this.textBox1.Text + " ";  output += "Address:" + this.textBox2.Text + " ";  output += "Occupation:" + this.textBox3.Text + " ";  output += "Age:" + this.textBox4.Text + " ";  this.textBox5.Text = output;   }  }  }

上述內(nèi)容就是C# 中怎么實(shí)現(xiàn)一個(gè)TextBox事件,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁(yè)題目:C#中怎么實(shí)現(xiàn)一個(gè)TextBox事件
文章網(wǎng)址:http://chinadenli.net/article4/ipscie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃網(wǎng)站收錄網(wǎng)站建設(shè)網(wǎng)站設(shè)計(jì)公司定制網(wǎng)站定制開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)