有个主窗口,副窗口打开以后就关不了了。
其他的窗口没什么问题。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using jxsm.pnjx.model;
namespace jxsm.pnjx
{
public partial class FrmLogin : Form
{
private Boolean bCloseFlag = false;
public FrmLogin()
{
InitializeComponent();
}
private void FrmLogin_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = !bCloseFlag;
}
private void btnLogin_Click(object sender, EventArgs e)
{
bCloseFlag = LoginInfo.getInstance().checkLogin(this.txtUser.Text, this.txtPass.Text);
if (bCloseFlag)
{
this.Close();
}
else
MessageBox.Show("输入的用户名或口令错误!", AppInfo.SYSTEM_INFO, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void txtUser_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
this.txtPass.Focus();
}
private void txtPass_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
this.btnLogin_Click(sender, e);
}
}
}
上边是子窗口的代码,应该没问题的。 按照这个写的其他窗口没问题