H
Hector Santos
I need this flow:
Main form is display. You select something, it displays another 2nd
form and the mainform is hidden. When the 2nd form is closed, it
shows the hidden main form again.
Do I need to keep a global public instance. In other words, I see in
the program.cs auto generated code it has:
namespace wcNavigatorCS
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new wcNavConnectSitesForm());
}
}
}
The wcNavConnectionSitesForm is the main form. So I change this to so
that it creates the new as a public instance?
What I did, probably clumsy, in the 2nd form FormClosing event, is this:
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
FormCollection fl = Application.OpenForms;
foreach (Form f in fl)
{
if (f.Name == "wcNavConnectSitesForm")
{
f.Show();
break;
}
}
}
Seems to work. Any problem with this method? It avoids having to
change auto-generated code like program.cs, but is that ok too?
Thanks
Main form is display. You select something, it displays another 2nd
form and the mainform is hidden. When the 2nd form is closed, it
shows the hidden main form again.
Do I need to keep a global public instance. In other words, I see in
the program.cs auto generated code it has:
namespace wcNavigatorCS
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new wcNavConnectSitesForm());
}
}
}
The wcNavConnectionSitesForm is the main form. So I change this to so
that it creates the new as a public instance?
What I did, probably clumsy, in the 2nd form FormClosing event, is this:
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
FormCollection fl = Application.OpenForms;
foreach (Form f in fl)
{
if (f.Name == "wcNavConnectSitesForm")
{
f.Show();
break;
}
}
}
Seems to work. Any problem with this method? It avoids having to
change auto-generated code like program.cs, but is that ok too?
Thanks