Showing Form at Run
-
I have an application which starts with:
public Form1() { InitializeComponent(); form = this; } private void Form1\_Load(object sender, EventArgs e) { textBox2.Text = "Initialising....."; this.Show(); Refresh();
When I run it from within VS the form appears as expected. When I publish the app, install it and then run I never see the form. Changing this.Show() to Form1.Show() gives error CS0120. Can anyone help?
-
I have an application which starts with:
public Form1() { InitializeComponent(); form = this; } private void Form1\_Load(object sender, EventArgs e) { textBox2.Text = "Initialising....."; this.Show(); Refresh();
When I run it from within VS the form appears as expected. When I publish the app, install it and then run I never see the form. Changing this.Show() to Form1.Show() gives error CS0120. Can anyone help?
Why on earth are you doing a Show and a Refresh in Form_Load? The form is drawn for the first time AFTER your Form_Load event handler returns. There's nothing to show yet and there's nothing to refresh! Remove those two lines of code:
private void Form1_Load(object sender, EventArgs e)
{
textBox2.Text = "Initialising.....";
}You also spelled "Initializing" wrong.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
Why on earth are you doing a Show and a Refresh in Form_Load? The form is drawn for the first time AFTER your Form_Load event handler returns. There's nothing to show yet and there's nothing to refresh! Remove those two lines of code:
private void Form1_Load(object sender, EventArgs e)
{
textBox2.Text = "Initialising.....";
}You also spelled "Initializing" wrong.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak