Application.Run
Hi there
When you execute
Application.Run(new Form1())
the Application will display Form1
It doesn't seem to work if you execute something like
Application.Run(getForm())
public static Form getForm()
{
Form Form1 = new Form();
return Form1;
}
assume that Form1 has controls and a proper constructor and InitializeComponent() method.
The second invocation of Run does not seem to display the form. Is there something I am missing here?
Master BillaPosted Oct 3, 2009, 10:58 PM
No it will work, i seem you your code have some issues.
Here my code for you.
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(GetForm());
}
private static Form GetForm()
{
return new Form2();
}
}
}
Thank you
Roei BarPosted Oct 3, 2009, 11:10 AM
and this is why it doesnt work :-)