Working with Multiple Forms using Visual C# 2008

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.


0

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

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

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

4

(6) Run the project by pressing F5 key. You can also run by selecting Start Debugging item from the Debug menu.

Figure 5

5


Like it? Share with your friends!

0

What's Your Reaction?

hate hate
0
hate
confused confused
0
confused
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
lol lol
0
lol
omg omg
0
omg
win win
0
win
Anand Narayanaswamy
Anand Narayanaswamy is the editor-in-chief of Learnxpress. He was a Microsoft Most Valuable Professional (MVP) for a period of 9 years. He is a ASPInsider based in Trivandrum, Kerala State, India. Anand is the author of Community Server Quickly published by Packt Publishing.

One Comment

Your email address will not be published. Required fields are marked *