Looking at VFP: Examples of form sets

Source: Internet
Author: User

This article is a small example of a form set. In this case, the status of the form Form2 in the form set is hidden, and the form Form1 the table above shows the data in the Site information table, as shown in the following figure:

After you click the Show additional Information command button, the text on the button changes to "Hide additional information," and the form Form2 displayed, and the table above shows the data in the "Additional Information table", and the data in the two tables above Form1 and Form2 enables data linkage. That is, clicking a record of a Web site in the Form1 table shows additional information about the site in the Form2 table. When the text on the command button changes to "Hide additional information," Click the command button to hide the Form2 again. The following figure

This example uses the "Data 1" database in the "Site information table" and "Additional information table", about the database is already looking at the case of VFP: sample database is given in the article. This example makes the following steps:

First, create a new form and save it as an example of a form set. Scx. With the Form designer open, click form → create form set in the menu bar, so you create a form set FormSet1 that contains a form Form1. We then add one more form to the form set, by clicking Form in the menu bar and adding a new form while the form designer is open, the form designer will have a form2 of the form, which, when added, Form1 the original form to cover it. You can drag Form2 's title bar down a bit and you'll see the two forms.

Second, set the properties of the two form, set the Form1 Caption property to the Site information table, Form2 Caption Property set to "Additional Information table", Form1 and Form2 the Width property values are set to the 300,height property values are set to 168, The form designer that is set up is the following figure:

Third, add Data Environment: Right-click Form1 blank, select the Data Environment command, "Data 1" in the "Site information table" and "Additional information table" Two tables to add to the form's data environment.

Four, in the Data Environment designer, by dragging the number field of the Site information table to the site number index identification of the additional information table, a single line appears between the site information table and the additional information table in the Data Environment designer. Indicates that a one-to-one temporary relationship has been established between the two tables (the following figure), which is established when the form is started, and is released when the form closes.

Five, drag the site information table's title bar from the Data Environment Designer to Form1, automatically generate a table, and set the properties of the table by table 1:

Property name Property value
Width 294
Height 137
Top 0
Left 0

Table 1

Then add a command button to the lower-right corner of the table Command1, the Caption property of the command button is set to show additional information, and a similar method, dragging the title bar of the additional information table from the Data Environment Designer to the Form2, automatically generates a table. and set the properties of the table according to table 1. The form designer that is set up is the following figure:

Vi. Add event code:

(1). Unload event code for form Form1: Close data

(2). Init event code for form Form1: Thisform.Parent.form2.Hide

(3). QueryUnload event code for the form Form1: Thisform.release

(4). command button Command1 Click event Code:

IF this. Caption= ' Show additional information ' this
   . Caption= ' Hide additional information '
   thisform. Parent.form2.Show
ELSE this
   . Caption= ' Show additional information '
   thisform. Parent.form2.Hide
ENDIF
Run "Example of a form set. Scx".

This example code is debugged in the win2003+vfp6.0 environment.

See the full set of "rookie also learn VFP" tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.