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

In Creating a simple Windows Forms application, we introduced the major windows of Visual Studio. Now let's explore the Properties Window, which enables you to visually set the behaviors of the controls, such as Button, TextBox, CheckBox, RadioButton, etc.

Create a new Windows Form application called MyInternetBrowser. Select the form and make the Properties Window appear through View > Properties (if it's not enabled already). The items of the Properties Window are sensitive to the control you select. If you click a property, such as (Name), a brief description of that property appears at the bottom (see Figure 1).


Name property
Fig. 1 A brief description of a property appears at the bottom.

As shown above, the Name property is used in code to identify a control. Therefore, changing its value has no effect to what a control appears. In order to make the application appear as My Internet Browser, you need to change the value of the Text Property correspondingly, as shown in Figure 2.


Text property
Fig. 2 Changing the Text property value changes a control's appearing text.

Next let's talk about the Anchor property, which you cannot find for the Form control. To see how this property works in action:

1) Set the Size property of the form as:

Property Value
Size 585,393

2) Drag a TextBox to the Form designer from Toolbox Window and set the corresponding properties as:

Property Value
(Name) textBoxURL
Text http://www.nlpdotnet.com
Size 456,20
Position 13,4
BackColor Info

3) Drag a Button to the Form designer from Toolbox Window and set the corresponding properties as:

Property Value
(Name) buttonGo
Text Go
Size 42,43
Position 475,1

The result so far should look like Figure 3.


With a TextBox and a Button added
Fig. 3 The result after adding a TextBox and a Button

4) Drag a WebBrowser to the Form designer from Toolbox Window and set the corresponding properties as follows, which will produce something like Figure 4.

Property Value
(Name) webBrowser1
Size 544,315
Url http://www.nlpdotnet.com

With a TextBox, a Button, and a WebBrowser added
Fig. 4 The result after adding a WebBrowser

Now run your application by Ctrl + F5. After a few seconds' loading time, you will see something like Figure 5. Maximizing the window gives rise to the ugly Figure 6.


Application in normal state
Fig. 5 Run the application by Ctrl + F5.

Application in maximized state
Fig. 6 After the window is maximized.

Obviously, our application looks awkward. To fix the problem:

1) Select the Form control and set its WindowState property to Maximized, as shown in Figure 7.


Set WindowState to Maximized
Fig. 7 Set the Form's WindowState to Maximized.

2) Select the WebBrowser control and set its Anchor property to Top, Bottom, Left, Right, as shown in Figure 8.


Set WebBrowser's Anchor to Top, Bottom, Left, Right
Fig. 8 Set the WebBrowser's Anchor property to Top, Bottom, Left, Right.

Now run your program again and you will see a complete web page like Figure 9. Try typing different addresses to see the results as well.


Pretty appearance of rerunning the application
Fig. 9 Setting the properties correctly results the pretty appearance.

In this tutorial, we learned the function of the Properties Window. We created a simple internet browser by appropriately setting the corresponding properties of the Form, the TextBox, the Button, and the WebBrowser controls. The best way to learn the properties of a control is to try changing their values and looking at the resulted changes by yourself. Of course, in order to know the exact cause of the visual change, you need to manipulate only one property each time. In the next tutorial, we'll take a look at the Solution Window.


Skip Navigation LinksHome > Visual Studio Tutorials > Properties Window