jonny_chympo
June 16th, 2008, 04:53 PM
Briefly:
Hi, I have a form A that opens a child form B (by clicking a button in form A). In form B, data is updated and form B is closed when the OK button is clicked. Because of the way I've implemented my database I need to create a new form A and delete the old one when form B closes - this will ensure my data is updated in form A.
I have tried the following (which makes sense in my head) but when I click the OK button on the NewPatientForm (form B), both form A and B close without displaying a new form A:
//Form A
public partial class EPTForm : Form
{
public EPTForm()
{
InitializeComponent();
}
private void btnNewPatient_Click(object sender, EventArgs e)
{
NewPatientForm frm = new NewPatientForm(this);
frm.ShowDialog();
}
}
//Form B
public partial class NewPatientForm : Form
{
EPTForm frmEptFormInstance = null;
public NewPatientForm(EPTForm frm)
{
InitializeComponent();
this.frmEptFormInstance = frm;
}
private void btnOk_Click(object sender, EventArgs e)
{
this.Close();
}
private void NewPatientForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.frmEptFormInstance.Close();
EPTForm eptFrm = new EPTForm();
eptFrm.Show();
}
}
I hope this explanation is clear enough, please let me know if you need clarification. Thanks for any help anyone can provide!
Hi, I have a form A that opens a child form B (by clicking a button in form A). In form B, data is updated and form B is closed when the OK button is clicked. Because of the way I've implemented my database I need to create a new form A and delete the old one when form B closes - this will ensure my data is updated in form A.
I have tried the following (which makes sense in my head) but when I click the OK button on the NewPatientForm (form B), both form A and B close without displaying a new form A:
//Form A
public partial class EPTForm : Form
{
public EPTForm()
{
InitializeComponent();
}
private void btnNewPatient_Click(object sender, EventArgs e)
{
NewPatientForm frm = new NewPatientForm(this);
frm.ShowDialog();
}
}
//Form B
public partial class NewPatientForm : Form
{
EPTForm frmEptFormInstance = null;
public NewPatientForm(EPTForm frm)
{
InitializeComponent();
this.frmEptFormInstance = frm;
}
private void btnOk_Click(object sender, EventArgs e)
{
this.Close();
}
private void NewPatientForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.frmEptFormInstance.Close();
EPTForm eptFrm = new EPTForm();
eptFrm.Show();
}
}
I hope this explanation is clear enough, please let me know if you need clarification. Thanks for any help anyone can provide!