Setting Properties: Using the Properties Window

All objects in the Visual Basic language, including forms and controls, have their own attributes that describe them. These attributes are known as properties. You can set the properties of a form and any controls on the form in the integrated development environment (IDE) by using the Properties window or by writing code in the Code Editor. For example, if you want to display text on a button, you can set the button's Text property, as shown in the following illustration. 

Properties Window

Properties Window

Try It!

To set the properties of a control

  1. On the File menu, click New Project.

    The New Project dialog box appears.

  2. Click Windows Forms Application and then click OK.

  3. Drag a Button control from the Toolbox to the form.

  4. If the Properties window is hidden, click the View menu, and then click Properties Window.

  5. Click the Button control and scroll through the properties in the Properties window to become familiar with them.

  6. Click the Text property, and then type Submit in the right-hand column.

    When you click an empty space in the Windows Forms Designer, the text on the button changes to Submit.

Docking a Control

You can dock a control to a location on a form so that it remains in the same location, even when the form is resized. For example, you can dock a control to the top of the form. This causes the control to appear at the top of the form, and causes it to extend from the left side of the form to the right side. If a user resizes the form, the control will remain docked to the top of the form, and it will expand to the width of the form.

You can choose to dock a control at the top, bottom, left, or right of a form. You can also choose to fill the form with the control. In the Properties window, when you click the drop-down arrow associated with the Dock property, a menu appears containing boxes that represent the top, left, center, right, and bottom of the form. If you click in the left square, the control will dock to the left side of the form. If you click in the center square, the control will fill the whole form.

To set the Dock property of a control

  1. Click the Button control and press the DELETE key to delete it from the form.

  2. Drag a RichTextBox control from the Toolbox to the form.

  3. Click the drop-down arrow next to the Dock property, and then click the center square.

    The RichTextBox control expands to fill the whole form.

Next Steps

In this lesson, you learned how to set the properties of a control by using the Properties window.

In the next lesson, you will learn how IntelliSense can help you write code quickly.

Next Lesson: Smart Coding: Using IntelliSense to Help You Write Code

See Also

Tasks

Rummaging Through the Toolbox

Concepts

Closer Look: Understanding Properties, Methods, and Events

Other Resources

Introduction to the Visual Basic Express IDE