Condividi tramite


Creating a New Form

Forms display the fields and records in your tables and views, and usually include navigation controls to help you move from record to record.

You can create forms in Visual FoxPro in any of these ways:

  • Use form wizards to create ready-to-use forms.
  • Choose Quick Form on the Form menu to create a simple form that you can customize by adding your own controls.
  • Use the Form Designer to modify existing forms or create your own forms.

Using a Form Wizard

Whenever you want to create a new form, you can use a form wizard to help you set it up. The wizard will ask you a series of questions and build a form for you based on your answers. You can choose from several different style options and preview your form before creating it.

To create a new form with a wizard

  1. In the Project Manager, select the Documents tab and select Forms.
  2. Choose New.
  3. Choose Form Wizard.
  4. Select the type of form you want to create.
  5. Follow the instructions on the wizard screens.

You can also access the form wizards from the menu by choosing the Wizards command from the Tools menu, and selecting Form.

Visual FoxPro provides two different form wizards to help you create forms:

  • To create a basic form based on one table, choose the Form Wizard.
  • To create a form that incorporates data from two tables linked in a one-to-many relationship, choose the One-to-Many Form Wizard.

Forms you create with the form wizards have a standard set of navigation buttons so you can display different records in the form, edit records, search for records, and so on. If you create a form within a database, the Form Wizard can use input mask and format settings stored in the database.

Starting the Form Designer

If you want to create your own form without using a wizard, use the Form Designer. With the Form Designer, you can add fields and controls to your form, and customize it by adjusting and aligning the controls.

The Quick Form command is provided to make it easier to get started creating a form. The Quick Form command displays the Form Builder, which adds selected fields from tables or views to your form.

To create a new form

  1. In the Project Manager, choose the Documents tab.

  2. Select the Forms icon.

  3. Choose New.

  4. Select New Form. The Form Designer window appears so you can begin creating your form.

    -or-

  • From the File menu, choose New, select Form, and choose New File.

    -or-

  • Use the CREATE FORM command.

Modifying a Form

If the wizard- or builder-generated forms don't quite fit your needs, you can modify them with the Form Designer. Using the Form Designer, it's easy to move and resize controls, copy or delete controls, align controls, and modify the tab order.

To modify a generated form

  1. In the Project Manager, select the Documents tab.
  2. Choose the Forms icon and select the name of the form.
  3. Choose Modify.

Adding Fields Quickly

When you want to quickly place the fields from a table or view into a form, choose Quick Form on the Form menu. Quick Form starts the Form Builder, which adds selected fields from a table or view to your form, using the field style you choose. The Form Builder creates a form without navigation controls, so you can add your own. You can use a control builder to add navigation controls to your form, or choose from the predefined library of navigation controls provided with Visual FoxPro.

To add fields to a form

  1. In the Project Manager, open the form.

  2. In the Form Designer go to the Form menu and choose Quick Form. The Form Builder appears.

  3. In the Style tab, select the style you want for the new control.

  4. In the Field Selection tab, select the source of the fields, and the fields you want to add.

  5. Choose OK to generate the form.

    -or-

  6. In the Form Controls toolbar, choose a data control and drag in the Form Designer window to create the control.

  7. In the Properties window, choose the Data tab and select the ControlSource property.

  8. Enter a field name.

    -or-

    Select a field from the list of available fields.

Using the Form Designer Toolbars

The Form Designer toolbars give you quick access to frequently used commands and the layout, alignment, and color controls you need when designing or modifying forms. For more information about the purpose of each button on each toolbar, you can use the ToolTips feature or search for "Toolbars".

See Also

Setting the Data Environment | Creating Forms | Creation of Single- and Multiple-Document Interfaces | Designing Forms | Adding Visual FoxPro Controls to a Form