I have Form1 & Form2 in my VC# 2008 project, in the Form1 I did:
private void Form1_Load(object sender, EventArgs e)
{
this.Hide();
Form2 frm2 = new Form2();
frm2.Show();
}
But when it is executed, the Form1 still existed and covers Form2 in its back, even I try the following in Form2 ... the result is the same:
private void Form2_Load(object sender, EventArgs e)
{
Form1 frm1 = new Form1();
frm1.Hide();
}
Anyone can help, thanks in-advanced (by the way, I don't want to add a Launch Form2 button in Form1)
Loading
Kevin AungPosted Jan 9, 2011, 12:11 PM
private void Form1_Load(object sender, EvenArgs e)
{
this.ShowInTaskbar = false;
this.Hide();
Form2 myForm = new Form2();
myForm.ShowDialog();
}
anhtruong52Posted Jan 9, 2011, 1:01 PM
Many thanks for help!
anhtruong52Posted Jan 9, 2011, 12:59 PM
Mant thanks for help
thiago costaPosted Jan 9, 2011, 12:46 PM
Form 1:
this.Hide();
form2 frm2 = new form2(this);
frm2.ShowDialog();
frm2.Dispose();
Form2:
//At the top of your code...
public partial class form2 : Form
{
private form1 _parent; //Add this
public form2(form1 form)
{
InitializeComponent();
_parent = form; //add this
}
Then, if you want to show form1 again you do.
this.Close();
_parent.Show();