Share via


Adding Visual FoxPro Controls to a Form

You can easily add any of the standard Visual FoxPro controls to your form by using the Controls toolbar.

Standard Visual FoxPro Controls

Check box
Hyperlink
List box
Spinner
Combo box
Image
OLE Bound Control
Text box
Command button
Label
OLE Container Control
Timer
Edit box
Line
Shape

You add new controls by selecting them from the Form Controls toolbar, and placing them in the Form Designer window. For example, you might want to add new labels for fields on the form, add new controls such as buttons, edit boxes, list boxes, and so on, or add pictures or lines and shapes to enhance the appearance of your form.

To add a control to a form

  1. Choose a control in the Form Controls toolbar.
  2. In the Form Designer window, drag to create a rectangle where you want the control to be, or click to create a control of default size.

The new control appears where you placed it. You can then move it to its final location on the form, and resize it as needed.

Adding Multiple Controls at One Time

When you choose the Button Lock button, you can add multiple controls of the same type without having to click the control button on the toolbar more than once. For example, if you want to add five text boxes to a form, make sure the Button Lock button is selected, and then click the text box control button in the Form Controls toolbar once and add all five text boxes to the form.

Button lock is automatically engaged if you double-click on a control button on the Form Controls toolbar. To turn button locking off, click the Button Lock button again or click the Selection Pointer button on the Form Controls toolbar.

Adding a Control with a Builder

If you want help adding a control, you can use a builder to add the controls and make them work with the form, or you can add the controls using the Form Controls toolbar and the Properties window.

Just as wizards can be used to construct forms quickly, builders can be used for adding controls to a form. The builder asks a series of questions related to the control you are adding to your form, and sets the appropriate properties to make the control work as desired.

For example, if you want to add a new text box to a form, the builder asks which style of text box you prefer and which table's field it should display.

Builders can be accessed in one of two ways: from the Form Designer shortcut menu, or by activating the Builder Lock button on the Form Controls toolbar when you add controls to a form.

To add a control with a builder

  1. In the Form Controls toolbar, select the Builder Lock button.
  2. Select the control you want from the Form Controls toolbar, and draw it on the form.
  3. Fill in the information on the builder tabs.

Using Builders for All Controls

By setting the Builder Lock button on the Form Controls toolbar, you can automatically use a control builder each time you add a control to a form.

To turn on the Builder Lock

  • In the Form Controls toolbar, click the Builder Lock button.

For more information about which control to choose, see Using Controls. For details on valid image control sources, see Graphics Support in Visual FoxPro

Adding Data-Bound Controls to a Form

You can bind controls to data in a table, view, table field, or view field by setting the ControlSource property of a control to a field or the RecordSource property of a grid to a table or view. But you can also create data-bound controls by dragging fields or tables to the form directly from:

The class of control created this way depends on the Field Mappings settings in the Properties tab of the Table Designer or the Field Mapping tab of the Options dialog box.

By placing the tables or views associated with your form in the data environment for your form, you make it easy to bind new controls to the fields in the tables or views.

The ControlSource property field displays the fields available in the Data Environment Designer so you can select the one you want to bind to a control.

Displaying the Properties Window

The Properties window displays all the properties for the controls you add to a form. You use the ControlSource property in the Properties window to bind the control you have added to your form to a specific field in the table in your Data Environment Designer.

To display the Properties window

  • From the View menu, choose Properties.

    Note   If you want to use the Properties window to set control properties, make sure Builder Lock is turned off.

See Also

Adding Visual FoxPro Containers | Adding User-Defined Objects to a Form | Creating Forms | Addition of Objects to Forms | Adding Properties and Methods to a Form | Table Designer | Field Mapping | Adding Controls to a Form with the Component Gallery | Adding Controls to a Wizard-Generated Form | Adding User-Defined Objects to a Form | Selecting, Moving, and Resizing Form Controls | Aligning Controls in Forms | Setting Tab Order for Controls | Setting the Data Environment