Move one form to another winforms - C #

I have 2 winforms Form 1 and Form 2. I have button1 in form1, when I click button1 from form1 i, I display form 2.

Form2 ins = new Form2(); ins.MdiParent = this.MdiParent; this.Hide(); ins.ShowDialog(); 

I hide form1 to display form2 when button1 is pressed. This creates a click effect, and I need to remove that click. How to open / redirect to another form (I should show only one form at a time, and I should not show any main menu, for example (if I use the MDIParent form). Only one active form.

Thanks Karthick

+4
source share
5 answers

It looks like you are trying to create a web style interface where the user navigates from one “page” (represented by a form) to another.

Instead of implementing an interface like this with separate forms, you'd better do it with UserControls hosted on the same parent form.

Read this MSDN article, which includes downloading with sample code. This is a great step-by-step guide for developing such a user interface:

IUI and Web-style Navigation in Windows Forms, Part 1

IUI and Web Form Navigation in Windows Forms, Part 2

Edit

If you intend to show two separate forms, is there any reason why you need to show the second version? Can't you just show it and then hide the original?

 form2.Show(); form1.Hide(); 

... or do you have another form in which forms form1 and form2 are "modal" ??

+3
source

To transfer from one page ( form1 ) to another ( form2 ), suppose that form1 contains a button with the name "SAVE", we should write the following code in the click event of the SAVE button

 form2 f2=new form2(); f2.Show(); 
+2
source

I think there is a property on winforms if you want to show it on the taskbar or not.

0
source

Instead of hiding, use the close option.

 Form1 formObject = new Form1(); formObject.Close(); 

or simply

 this.Close(); 
0
source

I can clarify your doubts about how to redirect from one form1 to form2

for example: put the link in form1 and then write the following code in it

 form2 ins=new form2(); ins.show(); 
0
source

All Articles