You will need to work with more than one form while developing Windows based applications in C#. In this code snippet, Anand examines the steps required using Visual C# 2008
(1) Start Visual Studio 2008 (Start | All Programs | Microsoft Visual Studio 2008 | Microsoft Visual Studio 2008)
(2) Create a new C# project from File | New | Project. The New Project dialog box opens up as shown in Figure 1. Modify the project name and change the target directory if required.
Figure 1
(3) A new form with the title Form1 appears on the screen. Add a Button control to it from the Toolbox. Change the caption to OK by altering the Text property from the Properties window.
Figure 2
(4) Add another form to the project by selecting Add Windows Form item from Project menu. Add a Label control to it and change its text as “This is Form 2”
Figure 3
(5) Activate Form 1 by double clicking Form1.cs from Solution Explorer. Double click the Button control and add the following code
Form2 f2 = new Form2();f2.Show();Figure 4
(6) Run the project by pressing F5 key. You can also run by selecting Start Debugging item from the Debug menu.
Figure 5
Thanks a lot!!!