问题
I have 2 winforms Form 1 and Form 2. I have button1 in form1, when i click on button1 from form1 i display form2.
Form2 ins = new Form2();
ins.MdiParent = this.MdiParent;
this.Hide();
ins.ShowDialog();
I hide the form1 to display form2 when button1 is clicked. This creates a flicking effect and i need to remove this flicking. How do i open/redirect to another form (i am supposed to show only one form at a time and am not supposed to show any top menu like (if i use MDIParent form). Just one active form.
Thanks, Karthick
回答1:
It sounds a bit like you're trying to create a web-style UI where the user steps from one "page" (represented by a Form) to another.
Rather than implementing a UI like this with separate forms, you're better off doing it with UserControls hosted on a single parent form.
Have a read of this MSDN article, which includes a download with sample code. It's a great walkthrough for designing that kind of user interface:
IUIs and Web-Style Navigation in Windows Forms, Part 1
IUIs and Web-Style Navigation in Windows Forms, Part 2
Edit
If you're intent on showing two separate forms, is there any reason you need to show the second one modally? Can you not simply show it and then hide the original?
form2.Show();
form1.Hide();
... or do you have yet another form that both form1 and form2 are "modal" to?
回答2:
To transfer from one page (form1
) to another (form2
)
suppose form1
contain a button named "SAVE"
we have to write the following code in click event of the "SAVE" button
form2 f2=new form2();
f2.Show();
回答3:
I think there is a property on winforms if you would like to show it on the task bar or not.
回答4:
I can clarify your doubt about how to redirect from one form1 to form2
for example: place a link in form1 and then write following code in it
form2 ins=new form2();
ins.show();
回答5:
Instead of hide use close option.
Form1 formObject = new Form1();
formObject.Close();
or simply
this.Close();
来源:https://stackoverflow.com/questions/1463513/move-one-form-to-another-winforms-c-sharp