欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

玩欧卡就用莱仕达V10方向盘欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 5969|回复: 0
收起左侧

一个退出窗体的问题

[复制链接]
terkcov 发表于 2012-1-7 02:35 | 显示全部楼层 |阅读模式
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace regist
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Application.ExitThread();
        }

        private void txtName_Validating(object sender, CancelEventArgs e)
        {


            if (txtName.Text.Trim() == string.Empty)
            {
                MessageBox.Show("用户名为空,请重新输入!");
                txtName.Focus();
            }
        }

        private void txtPwd1_Validating(object sender, CancelEventArgs e)
        {
            if (txtPwd1.Text.Trim() == string.Empty)
            {
                MessageBox.Show("密码为空,请重新输入!");
                txtPwd1.Focus();
            }
        }

        private void txtPwd2_Validating(object sender, CancelEventArgs e)
        {
            if (txtPwd2.Text.Trim() == string.Empty || txtPwd2.Text != txtPwd1.Text)
            {
                MessageBox.Show("两次密码不一致  请重新输入!");
                txtPwd2.Focus();
            }
        }

        private void txtEmail_Validating(object sender, CancelEventArgs e)
        {
            if (txtEmail.Text.Trim() == string.Empty || txtEmail.Text.Contains("@") == false)
            {
                MessageBox.Show("邮件地址格式错误,请重新输入!");
                txtEmail.Focus();
            }
        }

        private void txtName_Enter(object sender, EventArgs e)
        {
            txtMsg.Text = "请输入您的名字";
        }

        private void txtPwd1_Enter(object sender, EventArgs e)
        {
            txtMsg.Text = "请输入您的密码";
        }

        private void txtPwd2_Enter(object sender, EventArgs e)
        {
            txtMsg.Text = "请再次输入您的密码";
        }

        private void txtEmail_Enter(object sender, EventArgs e)
        {
            txtMsg.Text = "请输入您的邮箱地址";
        }

        private void btnOk_Click(object sender, EventArgs e)
        {

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {

            DialogResult result;
            result = MessageBox.Show("确定退出吗?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == DialogResult.OK)
            {

                Application.ExitThread();
            }
            else
            {
                e.Cancel = true;
            }

        }
    }
}

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-3-29 09:00 , Processed in 0.055093 second(s), 15 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表