English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi, I'm working with visual studio 2003, C#.NET, i've created 2 forms (form1 and form2), form1 calls form2 by clicking a button, when pressing the button form2 appears separated, i want form2 to be loaded on form1 or when loading form2 form1 must disappear, any body can help?

2006-12-29 08:00:14 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

form1.hide should work - after you have called form2.show

That's the VB-6 syntax anyway...not sure if it is exactly the same in .NET 03, but you should check out the Hide and Show methods of the form object.

2007-01-02 07:29:00 · answer #1 · answered by Richard H 7 · 0 0

You have two different options here. You can use MDI (multiple document interface) or you can simply hide the other form. I don't have the time or space here to go into MDI (it's not that hard really).
The easiest thing to do is simply call it like this:
Form1 frm = new Form1();
frm.Show();
this.Hide();
That will hide the previous form. If you want that form back, you'll have to pass it as a parameter to the new window so that you can call it's show() method again.

2006-12-29 17:42:19 · answer #2 · answered by Nathan 2 · 0 0

use the Show()/Hide() public methods of the Form objects or do this:

class form1
{
private void OnButtonClick()
{
form2 f2 = new form2(this);
f2.ShowDialog();
}
}

2006-12-29 16:31:49 · answer #3 · answered by T A 2 · 1 0

fedest.com, questions and answers