Windows Develop Bookmark and Share   
 index > Windows Forms General > How accessing a form1 from a form2...
 

How accessing a form1 from a form2...

Hi everyone...
I don´t know if this question has been posted before, but I really want to know How can I hide a form1 when a form2 has been laoded from the form1...

I hope be clear...
Thank you..
Lug Vélez Schmitz  Monday, February 05, 2007 2:14 AM

if just hide form14 is parent and form15 is child:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace __11

{

public partial class Form14 : Form

{

public Form14()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Form15 fm15 = new Form15(this);

fm15.Show();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace __11

{

public partial class Form15 : Form

{

private System.Windows.Forms.Form parent;

public Form15(System.Windows.Forms.Form p)

{

this.parent = p;

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

this.parent.Hide();

}

}

}

Bob zhu - SJTU  Monday, February 05, 2007 2:34 AM

if you want toStart another thread for the second form you can ues:

public static void ThreadProc()

{Application.Run(new Form());}

private void button1_Click(object sender, EventArgs e)

{

System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));

t.Start();

}

Bob zhu - SJTU  Monday, February 05, 2007 2:33 AM

if just hide form14 is parent and form15 is child:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace __11

{

public partial class Form14 : Form

{

public Form14()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Form15 fm15 = new Form15(this);

fm15.Show();

}

}

}

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace __11

{

public partial class Form15 : Form

{

private System.Windows.Forms.Form parent;

public Form15(System.Windows.Forms.Form p)

{

this.parent = p;

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

this.parent.Hide();

}

}

}

Bob zhu - SJTU  Monday, February 05, 2007 2:34 AM

You can use google to search for other answers

Custom Search

More Threads

• Errors while scrolling datagridview
• WebBrowser and file:// URLs?
• Layout
• Designing for multiple users - overall strategies?
• exceptions catches ignored VS 2005
• Problem with mdi. Close active form and not open already opned form??
• Unable to change languages using alt-shift when using my form
• Graph
• connection string on froms
• Limit the number of selected Items in a Listview