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.
- Open a new project.
- 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.
- With the Command1 button on the screen (see Figure 3.3), move it to the left-hand side of the form.
- Change the BackColor property using the BackColor palette to change the color.
- Run the program. What does the BackColor setting change?
- 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.
- Exit to return to the form.