Setting Properties for a Control - VISUAL BASIC TUTORIAL

About us

Ads Here

Wednesday, May 16, 2012

Setting Properties for a Control

After adding a control to a form, the properties of the control can be modified.  Control properties work in the same way as form properties:  They can be used to change the appearance or the behavior of the control.  Figure 3.3 shows the Properties dialog box for a command button.  Like a form, you can set a wide variety of options for a command.

Besides Caption and Name,command button properties include ways of changing the appearance of the text on the button, the size of the button, and even how you want the cursor to appear when it is placed over the button (the MousePointer property).  You cannot change the color of the button, as the next exercise demonstrates.

Figure 3.3 The properties box for a command button contains a Caption and a Name property and a host of other properties.

Exercise 3.1 Examining the Control Property Box

In this short exercise, you add a command button to a form and change its properties.

  1. Open a new project.
  2. Double-click the Command Button control.  If you place the wrong one on the form, select Edit, Delete to remove the control from the form.
  3. With the Command1 button on the screen (see Figure 3.3), move it to the left-hand side of the form.
  4. Change the BackColor property using the BackColor palette to change the color.
  5. Run the program. What does the BackColor setting change?
  6. Click the form and the Command button. Can you determine why nothing happens? Because you have not indicated what action (that is, what event) is to take place when the button is clicked, the piece missing is a procedure.
  7. Exit to return to the form.

No comments:

Post a Comment