Free language processing service and NLP C# code
Current topic Practical tutorials for Visual Studio

Suppose you have installed Visual Studio 2008 on your computer. Let's familiarize ourselves with the working environment by creating a simple Windows Forms application. Click Start>All programs>Microsoft Visual Studio 2008>Microsoft Visual Studio 2008 to start Visual Studio 2008. Then click File > New > Project as igure 1:

Create a new project
Fig. 1 Create a new project

This will bring up the New Project window. Select Visual C# for Property types and select Windows Forms Application from the Templates panel. Name your project IamWhoIam and uncheck Create directory for solution. If you don't want to save your project in the default location, click Browse to change its location. Leave everything else as they are (See Figure 2). Click OK to bring up the Form Designer like Figure 3.

New Project Templates
Fig. 2 New Project Templates

New Form
Fig. 3 New Form Designer

We will explore the details of the various parts of the new form designer in the course of the tutorials. For the time being, let's have a quick view of them. Form1 in the middle is the interface to be shown to the users. The left panel is the Toolbox which contains all the controls needed to create a Windows Forms application (see Figure 4). Look through the tools there to have a general idea.

Toolbox of Visual Studio
Fig. 4 Toolbox of Visual Studio

For this project, drag 2 buttons from Toolbox and drop them on Form1, which results in Figure 5:

2 buttons on form designer
Figure 5: 2 buttons on form designer

Now our project has three objects: one form and two buttons. The lower-right panel of Figure 3 is the Properties Window where you can set the properties of each of those three objects, as shown in Figure 6. The content of the Properties Window is sensitive to the object you select on the form designer. Let's have a try. Select Form1 by clicking it once and look through the items in the Properties window. Then select Button1 and you will notice that the items are not completely identical. Click a property and an explanation note will appear at the bottom. For this project, you don't need to set any properties.

Properties window of Visual Studio
Fig. 6 Properties window of Visual Studio

Now double click Button1 and you will be presented with the event handler placeholder. Switch back to the form designer and double click Button2 and something like Figure 7 below will show up.

Event handler placeholder of Visual Studio
Fig 7 Event handler placeholder of Visual Studio

Let's add some code to show what will happen when the user click these buttons as shown in Figure 8. Just copy the code as shown in Figure 8. The code simply means: when Button1 is clicked, if its text is "button1", the text changes to "Hello, who are you?"; otherwise its text changes to "button1". Similarly, when Button2 is clicked, if its text is "button2", the text changes to "I am who I am!"; otherwise its text changes to "button2".

Code inserted
Fig. 8 Code inserted

Now let's run the program by clicking Debug > Start Without Debugging or use Ctrl + F5, as shown in Figure 9. Try clicking Button1 or Button2 repeatedly to see the result. One possible result is like Figure 10.

Run the program
Fig. 9 Run the program

New Form
Fig. 10 See the result

In this tutorial, we learned the various windows of Visual Studio 2008 by creating and running a simple Windows Forms application. In the following tutorial, we will go to the details of the Properties Window.

Skip Navigation LinksHome > Visual Studio Tutorials > Visual Studio Windows