Using Buttons

In this section:

How to:

A button is a control that triggers an action when clicked.

For an example of how you can use a button, see the Maintain Getting Started manual.


Top of page

x
Procedure: How to Place a Button on Your Form
  1. Select the Button control in the Controls palette.
  2. Draw a rectangle on your form approximately where you want your button to be and at approximately the size you want.
  3. Type the text you want your button to have and press the Enter key. The text should be selected automatically when you created the button. If you want the text to appear on more than one line, press Shift+Enter between each line.
  4. Giving your button a more meaningful name than Button is optional but recommended.
  5. If necessary, readjust the size and placement of your button.

    Note: If you click on the text of a button, you will be in text editing mode (when the text jumps to the top of the button and is selected). If you click near the edges of the button, you will be in move/resize mode. To change to a different mode, deselect the button and select it again.

  6. Assign a Click action to your button using the Event Handler editor.

    Tip: You can open the Event Handler editor by double-clicking the button.

    For more information on assigning actions to events, see Defining Events and Event Handlers.


Top of page

x
Changing Button Properties

When you select your button, you will see a list of button properties in the property sheet. Changing these properties will change what your button looks like and what it does at run time.

Many of the styling properties can also be changed using a Cascading Style Sheet. For more information on Cascading Style Sheets, see Using Cascading Style Sheets.

Choose your property based on the task you wish to perform:

If you want to change the text displayed in the button, use the Text Property. For more information, see the Text Property.

If you want to change the name of the button that identifies it to the procedure, use the (Name) Property. For more information, see the (Name) Property.

If you want to change the size or location of the button, use the Bottom Property, Left Property, Right Property, Top Property, or use a style sheet. For more information, see the Bottom Property, Left Property, Right Property, and Top Property. You can also move or resize the button directly in the form.

If you want to change the color of the button, use the BackColor Property to determine the color of the button, the ForeColor Property to determine the color of the text in the label, or use a style sheet. For more information, see the BackColorOver Property and the ForeColor Property.

If you want to change the text font, use a style sheet or use the Font Property. For more information, see the Font Property.

If you want to make the button inactive or make it invisible, use the Enabled Property to determine whether the button is active or not. If the button is inactive, it will be dimmed out and nothing will happen when the end user clicks it. You can also use the Visible Property to determine whether the button is visible to the end user or use a style sheet. For more information, see the Enabled Property and the Visible Property.

If you want to change what the cursor looks like when it is on top of the button, use the CursorPointer Property or use a style sheet. For more information, see the CursorPointer Property.

If you want to display a tooltip when the cursor is on the top of the button, use the ToolTipText Property. For more information, see the ToolTipText Property.

If you want to assign a Help topic to the button, use the Help Property. For more information, see Assigning Help to Your Forms and Controls.

If you want the end user to be able to tab to the button, use the Tabstop Property. For more information, see the Tabstop Property.

If you want to make the event handler for clicking the button occur when the end user presses the Enter key, use the DefaultButton Property. For more information, see the DefaultButton Property.

If you want to move the button to another layer, use the Layer Property. For more information, see Layering Controls.

If you want to control the display order of the button when more than one control is overlaid, use the ZIndex Property. For more information, see the ZIndex Property.


WebFOCUS