VFP Tutorial - Form Designer
As with any other Windows development tool, the form is the basic
interface for the user in Visual FoxPro.
FoxPro has a Form Wizard which will produce a good-looking form very
quickly but the design relies on a number of complex class libraries
and is difficult to understand or modify. We will build a straightforward
form by hand.
Create a form
Click on the tab of the Project
Manager then right-click on . Select
then
from the dialog.
The Form Designer will appear:
The screen shot shows the Form Designer and the Form Controls toolbar with
the mouse positioned above the Button control.
Add data
The form has to be connected to a data table. Right-click on the form and
select
.
A directory tree will open so that you can select a table. Click on
CD.dbf then close the Add Table dialog. This should leave you with the
form and the Data Environment windows visible:
Use the mouse to select the six fields from the Data Environment and drag
them to the form. If you do this with a normal left-click then FoxPro will
automatically create a grid control for the fields. Start the drag with a
right-click instead.
When you drop the files a menu will appear with the option of showing the
fields as a grid or as multiple controls. Select the
option. Make sure that you move the mouse to the top-left corner of the
form before you drop the fields. Some of the fields are quite wide and you
might have to make the form a bit larger to accept them it. Just click on
the form border and drag it to the size you want.
Close the Data Environment and leave the Form Designer on screen.
Run the form
Click the red exclamation mark on the toolbar or select
from the
menu.
You will be asked to save the form before you can run it. FoxPro will
suggest a name something like 'Form1.Scx'.Change this to 'MyCD.scx' or
something more suitable.
Moving and adjusting the size of controls
The obvious way to do this is to drag with the mouse and this is the
fastest technique for making crude adjustments. Use the cursor keys for
fine adjustments. Each key will nudge the control one pixel in the
appropriate direction. Hold down
and use the cursor keys to stretch or shrink the control by one pixel at a
time.
The menu has options to align and
size groups of controls. You can select multiple controls by
shift-clicking on the controls one-by-one or by dragging a selection
marquee around the group of controls. The selection marquee does
not have to surround a control, it will select any control that it
touches.
Improve the appearance of the form
The form will appear on screen and show the first record in the table but
that's all that it will do. It also needs a lot of work on its cosmetic
appearance. The captions are all at default values and the colour is just
the basic Microsoft grey. All these can be improved by altering the
properties of the form and controls. Properties are covered in the next
page.
Introduction |
Environment |
Project |
Tables |
Forms |
Navigation |
Executable
|