日期:2014-05-16  浏览次数:20917 次

C#入门经典 TextBoxtTest
 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            this.btnOk.Enabled = false;

            this.txtAddress.Tag = false;
            this.txtAge.Tag = false;
            this.txtName.Tag = false;
            this.txtOccupator.Tag = false;

            //验证
            this.txtName.Validating += new System.ComponentModel.CancelEventHandler(this.txtBoxEmpty_Validating);
            this.txtAddress.Validating += new System.ComponentModel.CancelEventHandler(this.txtBoxEmpty_Validating);
            this.txtAge.Validating += new System.ComponentModel.CancelEventHandler(this.txtBoxEmpty_Validating);

            this.txtOccupator.Validating += new System.ComponentModel.CancelEventHandler(this.txtOccupator_Validating);

            //this.txtAge.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtAge_KeyPress);


            this.txtName.TextChanged += new System.EventHandler(this
                .txtBox_TextChanged);
            this.txtAddress.TextChanged += new System.EventHandler(this
    .txtBox_TextChanged);
            this.txtAge.TextChanged += new System.EventHandler(this
    .txtBox_TextChanged);
            this.txtOccupator.TextChanged += new System.EventHandler(this
    .txtBox_TextChanged);
            //this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
            //this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
        }
        /// <summary>
        /// ok键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
 &n