Saturday, May 22, 2010

Visual C# Question: How do I use a button to lead to another form?

Like an installation wizard, for example. You have a window that pops up(Form1), there is a next button. The next button leads to another form(Form2). Asking where to install a file. Choose where to install, then click install. After it writes all the files from your installation program, it notifies you in the same window(Form3) that installation has completed. There is a button to close the wizard, everything is completed.





I know all those button commands, al I need to know if how to advance to another window or Form using the same size as the first one. Thanks!

Visual C# Question: How do I use a button to lead to another form?
Wizards are displaying one 'form' and switching the content pages. You can accomplish that on your form by changing the "Visible" properties of the elements on the form. Use a GroupBox to link elements together and show or hide the GroupBox.





It is easy to open a new form in the same spot and same size as the existing form, but better to simply switch the content in the current form. So, the Next button doesn't actually open another form. The code for opening a new form is simple:





Form myForm = new FormWhatever();


myForm.Show(); //or ShowDialog();


No comments:

Post a Comment