黑马程序员--winform入门

        通过对视频的学习,对winform有了一个大致的了解和认识。。。winform是有多个控件来实现的,控件就是winform中抽象的一些类, 包括button(按钮)文本框(textbox)

标签(label)    单选按钮(Radiobutton)、复选框(CHeckBox)

        在这里我们贴上几个简单的代码来让大家对winform有更直观的认识、

  实例一、 对email   的分析,将用户输入的email信息进行分割、、

     public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }


        private void button1_Click(object sender, EventArgs e)
        {
            string email = textBox1.Text;
            string[] str = email.Split('@');
            if (str.Length != 2)
            {
                MessageBox.Show("输入的Email地址非法");
                return;
            }
            textBox2.Text = str[0];
            textBox3.Text = str[1];
        }


        private void label2_Click(object sender, EventArgs e)
        {


        }
    }


 实例2、、   一个经典的简单的  登陆页面。

   public partial class Form1 : Form
    {
        private int ErrorTimes=0;
        public Form1()
        {
            InitializeComponent();
        }


        private void btnlogin_Click(object sender, EventArgs e)
        {
     
            string username = txtUserName.Text.Trim();
            string password = txtPassword.Text.Trim();
            if (username == "admin" && password == "888888")
            { MessageBox.Show("登陆成功"); }
            else
            {
                ErrorTimes++;
                if (ErrorTimes >= 3)
                {
                    MessageBox.Show("错误次数过多,程序即将退出");
                    Application.Exit();
                }
                MessageBox.Show("登录失败");
            }
        }


        private void Form1_Load(object sender, EventArgs e)
        {


        }
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值