See the example of VFP: text box control

Source: Internet
Author: User
Tags arrays copy

Text box control (textbox) is mainly used to receive or display data, in VFP is a common control, almost every program to use it. The basic course of VFP-text box (textbox) control and VFP Basic tutorial-the array has been introduced to the text box controls and arrays, and this article designs an example that combines the two.

About the processing of a text box control data Source:

If you use the Data environment in your form, you can drag the fields from the table to the form in the Data Environment Designer. The system automatically generates labels and text boxes for each field, and the data source for the text box is automatically bound to the corresponding field in the table, which is a way to handle it, and you can not use the data environment. This is an example of how the text box is added to the form, and then the data source is assigned to the text box at design time or runtime in code, as follows:

In the previous illustration, the related property values, such as the data source of each text box control on the form, are used in the same way as in the case of a case study VFP: Analog VB control array Operation Label Control example in a similar manner, see the code in the note.

The production steps are as follows:

To create a new form, set its Caption property value to "a programming portal-a comprehensive application of text boxes and arrays," saved as "form 1.scx".

Add three Label control Label1~label3 to the form, set their Caption property values to numbered, site name, and site URL, and arrange the three label controls in one column.

Three, add three text box controls to the form TEXT1~TEXT3, and align them in a column with the label1~.

Iv. add four command button Command1~command4 below the form, and set their Caption property values to "first", "previous", "Next", and "last".

Five, adjust the position of each control appropriately, adjust the form designer the following figure:

Vi. Add event code:

1, the form of the Init event code:

Set Safety off Use
Web site information table
Copy to structure structure extended && Copy site information table structure use structure go top
dime Stru (3 && defines the array do-while
!eof ()
   Select structure for
    i=1 to 3
      mt1= "text" +alltrim (str (i))
      thisform. &mt1.. Backstyle=0 && Sets the BackStyle property value for the text box to 0
      thisform.&mt1 ... Disabledforecolor=rgb (0,0,255) && Specifies the foreground color THISFORM.&MT1 of the failed control
       ... Enabled=.f. && sets the Enabled property value of the text box to. F.
      Stru (I) = structure. Field_name && Assign the Field_name field value of the structure table to three array elements in turn
    endfor enddo use
Web site Information table For
j=1 to 3
    sjy=alltrim ("Site information table.") +stru (j))
    mt2= "text" +alltrim (str (j))
    thisform.&mt2 ... Controlsource=sjy && assigns a data source to three text box controls in turn
endfor

2, the form of the Unload event code: Close Data

3, "First" command button Command1 Click event Code:

If BOF () =.f.
 Go top
endif
Thisform.refresh

4, the "Previous" command button Command2 Click event Code:

If BOF () =.f.
 Skip-1
endif
Thisform.refresh

5, "Next" command button Command3 Click event Code:

If EOF () =.f.
  Skip
endif
Thisform.refresh

6, "Last" command button Command4 Click event Code:

If EOF () =.f.
 Go bottom
endif
Thisform.refresh

Seven, run "form 1.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.