vecowski
March 25th, 2010, 11:25 AM
Hey,
I'm having a problem with my windows form application program I am creating. The first form loads, which is a form for a user to log in, there are 2 text boxes and 4 buttons. 1 of the buttons, register, creates a new object of type frmRegister which just links to a windows form I created. When this new form loads, I hide the current one which is the login form. However, if I click the X button on frmRegister it closes the entire application. It does this even those I have a function in frmRegister that handles the formclosed event which all it does is hide the frmRegister. I'll do my best to paste code.
This is the method that handles the event from the register button on the login form being clicked.
private void btnRegister_click(object sender, EventArgs e)
{
frmRegister objfrmRegister = new frmRegister(this);
this.Hide();
objfrmRegister.Show();
}
And my class frmRegister
public partial class frmRegister : Form
{
frmLogin objfrmLogin;
public frmRegister(frmLogin temp_objfrmLogin)
{
InitializeComponent();
this.objfrmLogin = temp_objfrmLogin;
}
private void btnRegister_Click(object sender, EventArgs e)
{
database db = new database();
db.registerUser(username.Text, password.Text);
this.Hide();
this.objfrmLogin.Show();
}
private void controlExit_Click(object sender, FormClosedEventArgs e)
{
this.Hide();
this.objfrmLogin.Show();
}
}
}
Keep in mind it acts the same way whether I exit out of the register form or actually invoke the method btnRegister_click through the event of my register button being clicked.
Thanks for your help, if you need more code let me know.
I'm having a problem with my windows form application program I am creating. The first form loads, which is a form for a user to log in, there are 2 text boxes and 4 buttons. 1 of the buttons, register, creates a new object of type frmRegister which just links to a windows form I created. When this new form loads, I hide the current one which is the login form. However, if I click the X button on frmRegister it closes the entire application. It does this even those I have a function in frmRegister that handles the formclosed event which all it does is hide the frmRegister. I'll do my best to paste code.
This is the method that handles the event from the register button on the login form being clicked.
private void btnRegister_click(object sender, EventArgs e)
{
frmRegister objfrmRegister = new frmRegister(this);
this.Hide();
objfrmRegister.Show();
}
And my class frmRegister
public partial class frmRegister : Form
{
frmLogin objfrmLogin;
public frmRegister(frmLogin temp_objfrmLogin)
{
InitializeComponent();
this.objfrmLogin = temp_objfrmLogin;
}
private void btnRegister_Click(object sender, EventArgs e)
{
database db = new database();
db.registerUser(username.Text, password.Text);
this.Hide();
this.objfrmLogin.Show();
}
private void controlExit_Click(object sender, FormClosedEventArgs e)
{
this.Hide();
this.objfrmLogin.Show();
}
}
}
Keep in mind it acts the same way whether I exit out of the register form or actually invoke the method btnRegister_click through the event of my register button being clicked.
Thanks for your help, if you need more code let me know.