Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Windows form application problem
 

Windows form application problem

when we create a Windows form application
In file Form1.Designer.cs show lines below:

1 this.ResumeLayout(false);

2 this.PerformLayout();

3 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

4 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

And in Program.cs :

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());

}

When i Wanto destroy form1 and create form2 What should i do to form2 appear?

Can You explain the meaning,please?
Thanks
cotdot11111  Wednesday, May 20, 2009 1:02 AM

Hi cotdot11111,

If you mean popup form2 when you click a button in form1, so form1 cannot be close after form2 is shown. You can set form1's Visible to false and close it after form2 is close.
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
this.Visible = false;
form2.ShowDialog();
this.Close();
}
If you want to show form2 after form1 is closed, you can change Program.cs into this.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new Form2());
}

Hope this help you.

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, May 21, 2009 7:23 AM

Hi cotdot11111,

If you mean popup form2 when you click a button in form1, so form1 cannot be close after form2 is shown. You can set form1's Visible to false and close it after form2 is close.
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
this.Visible = false;
form2.ShowDialog();
this.Close();
}
If you want to show form2 after form1 is closed, you can change Program.cs into this.
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new Form2());
}

Hope this help you.

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Thursday, May 21, 2009 7:23 AM

You can use google to search for other answers

Custom Search

More Threads

• DesignVision
• Msn mesennger troughput isa server 2004
• Run time Create controls
• where to start?
• One question about Authentication XML Web Service!!
• tab pages
• CRM 3.0 sample senario
• TaskVision Server source.
• .Net 2005
• DataGrid View