Sunday, July 12, 2009

I have a problem with C#.NET, any body can help?

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?

I have a problem with C#.NET, any body can help?
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.
Reply: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.
Reply: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();


}


}


No comments:

Post a Comment