一个退出窗体的问题
代码如下:程序代码:
using System; using System.Collections.Generic; using 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; } } } }
当我点击右上角的×时 总是弹出那个mbx 不知道怎么解决 自己的思路是 是否在点击×的事件里 添加一段代码 功能就是把控件屏蔽掉
牛人看看啊 还有就是我的退出按钮没有用