Know a good article or link that we're missing? Submit it!
*/

Other Views

corner
*/

WinForm FAQ - Adding a New Form at Design Time

How do I add another form into my win form application?

To add and design a new form at design time, right click the target project node in the Solution Explorer and select AddàAdd Windows Form… This will add a new form; design it by placing controls and setting necessary properties.

To show the new form at run time, instantiate the new form and call its Show() or ShowDialog() method.

Let we name the new form as ‘MySecondForm’, then on the click event of the button of our first (startup) form, we can write the following code:

C# Version

MySecondForm frm2 = new MySecondForm();
frm2.Show();	// will present the non-modal form
// frm2.ShowDialog(); 	// will present the modal form


VB.NET Version

Dim frm2 As New MySecondForm()
frm2.Show()		' will present the non-modal form
' frm2.ShowDialog() 	'will present the modal form


Index
corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings