文本类型控件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            label6.Hide();
        }

   

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                label3.Show();
                return;
            }else{
                label3.Hide();
                return;
            }

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            if (textBox2.Text == "")
            {
                label4.Show();
                return;
            }
            else
            {
                label4.Hide();
                return;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "hanxuyao" && textBox2.Text == "123456")
            {
                label6.Text = "正确";
                label6.ForeColor = Color.Green;


                label6.Show();
            }
            else 

            {
                label6.Text = "错误";
                label6.ForeColor = Color.Red;
                    


                label6.Show();
            }

        }

        
    }
}

 

posted @ 2024-06-22 15:16  hanxuyao  阅读(9)  评论(0)    收藏  举报