H
Hector Santos
I'm new to C#.NET and Winforms.
I'm porting an MFC based applet to C#.NET and the main form has a tool
strip with bottons. The first button display another form:
public partial class MainForm : Form
{
MyOtherForm form1;
...
private void toolStripButton1_Click(object sender, EventArgs e)
{
// create or "recreate" closed form and show it.
// no duplicate forms.
....
}
}
Of course, I can do this:
form1 = new MyOtherForm();
form1.Show();
and will create a new instance of the form.
I need to have it to be one form only and when closed, recreate and/or
reshow it. I tried this:
if (form1 == null)
{
form1 = new MyOtherForm();
}
form1.Show();
and that works until the form is closed.
Sounds so simple. I looked at the all the members to see what is
needed there. I remember not, but if thats the only way, to have an
clumsy form1 to parent destroy event to reset form1 = null. Some
member in the class has to tell me it has been closed and/or need to
create a new instance.
Sounds so simple.
TIA
I'm porting an MFC based applet to C#.NET and the main form has a tool
strip with bottons. The first button display another form:
public partial class MainForm : Form
{
MyOtherForm form1;
...
private void toolStripButton1_Click(object sender, EventArgs e)
{
// create or "recreate" closed form and show it.
// no duplicate forms.
....
}
}
Of course, I can do this:
form1 = new MyOtherForm();
form1.Show();
and will create a new instance of the form.
I need to have it to be one form only and when closed, recreate and/or
reshow it. I tried this:
if (form1 == null)
{
form1 = new MyOtherForm();
}
form1.Show();
and that works until the form is closed.
Sounds so simple. I looked at the all the members to see what is
needed there. I remember not, but if thats the only way, to have an
clumsy form1 to parent destroy event to reset form1 = null. Some
member in the class has to tell me it has been closed and/or need to
create a new instance.
Sounds so simple.
TIA