Look at the example of VFP: The Use of page box controls

Source: Internet
Author: User
Tags exit empty

The page box (pageframe) is also a basic control of VFP, use it can produce similar to the Effect of Windows dialog box, about the common properties and methods of this control please refer to VFP Basic Tutorial-page box and page a article.

The page box control itself is a container that can contain several pages, and a page is also a container in which you can add various objects, so adding objects or code references at design time is more troublesome than other controls. When you use this control, you need to be aware that if you want to add an object to a page at design time, be sure to select the label for the page in the edit State of the page box, and then add the control to the page, and you need to deal with the data source when you switch between different pages.

Comrades who have just come into contact with this control may often encounter such a problem: even if only two pages are set in the page box, the title widths of the two pages are evenly distributed and fill the width of the entire page frame, while in the standard Windows dialog box, the page headings are left aligned, regardless of the number of pages, as shown in the following figure:

This problem is very good to solve, the page box Tabstyle property value set to "1-not both ends" can come out of this left-aligned effect.

This article is designed to design an application instance of a page box control, in this example, the two pages of the page box control are implemented to see the example of VFP: Locating and locating records in a table and looking at examples VFP: To add records to a datasheet and verify that the input data is valid for two examples, run the following figure:

The production steps are as follows:

First, create a new form, set its Caption property value to programming Getting Started Network-page box control, and set the AutoCenter property value to. T., saving as "form 1.scx".

Add a page box control pageframe1 to the form and set its PageCount property value to the 2,tabstyle property value set to 1-not both ends.

Third, right-click the Page box control select the Edit command, in the edit state of the page box, select Page1, set its Caption property value to find records, and follow the example to learn VFP: locating and locating records in a table add the same control to Page1 and set the same properties for each control.

Iv. in the edit state of the page box, select Page2, set its Caption property value to add record, and follow the example to learn VFP: Add a record to a datasheet and verify that the input data is legitimate a text adds the same control to the Page2 and sets the same properties for each control.

The form designer after Setup is as follows:

Vi. Add event code:

(i) Init event code for the form:

&& coded by www.bianceng.cn this. MAXBUTTON=.F. && Maximize button for mask form this.
Minbutton=.f. && screen Minimize button this.pageframe1.activepage=2 && specify that the second page is the current page set exact on use Web site information table This.pageframe1.page1.combo1.value= "numbered" with This.pageframe1.page1.grid1. width=290. height=100. left=0. t
    Op=0. recordsource= "Website Information table". Deletemark=.f.
    . visible=.t.
    . readonly=.t. . Columncount=3. column1.header1.caption= "Number". Column1.header1.backcolor=rgb (255,255,190). Column2.header1.backcolor=rgb (255,255,190). column2.header1.caption= "website name". Column3.header1.backcolor=rgb (255,255,190). column3.header1.caption= "website url". Column1.width=75. Column2.width=80. column3.width=150 endwith with This.pageframe1.page2.grid1. height=100. left=0. top=0
    Rdsource= "Web Information table". Deletemark=.f.
    . visible=.t.
    . readonly=.t. . Columncount=3. column1.header1.caption= "Number". Column1.header1.backcolor=rgb (255, 255,190). Column2.header1.backcolor=rgb (255,255,190). column2.header1.caption= "website name". Column3.header1.backcolor=rgb (255,255,190). column3.header1.caption= "website url". Column1.width=75. Column2.width=80.
column3.width=150 endwith this.pageframe1.page1.grid1.Setall ("Dynamicbackcolor", "RGB (224,225,255)", "Column")
 This.pageframe1.page2.grid1.Setall ("Dynamicbackcolor", "RGB (224,225,255)", "Column")

(ii) The Unload event code for the form:

Close all
Set Exact off

(iii) event codes for each object in Page1 ("Find Records"):

1, Page1 activate event code:

This.refresh

2, "Find" button Command1 Click event Code:

If empty (Thisform.pageframe1.page1.Text1.value) =.f.
Go top
a=thisform.pageframe1.page1.combo1.value
B=alltrim (thisform.pageframe1.page1.Text1.value)
  if A= "Number"
     locate for number =b
     if EOF ()
        MessageBox ("The record you want to query does not exist in the database", 16, "System Prompt")
     else Go
        recno ()
     endif
  endif
  if a= "site name"
     Locate for Site name =b
     if EOF ()
        MessageBox ("The record you want to query does not exist in the database", 16, "system prompts"
     Else Go
        recno ()
     endif
  endif
  if a= "website url" Locate for Web site
     URL =b
     if EOF ()
        MessageBox ("The record you want to query in the database", 16, "system hint")
     else Go
        recno ()
     endif
  endif
  Thisform.pageframe1.page1.grid1.setfocus
Else
   MessageBox ("Please enter the content you want to find!") ", 16," system hint ")
   thisform.pageframe1.page1.text1.value=" "
   thisform.pageframe1.page1.Text1.Setfocus
endif return

3, "Restore" button Command2 Click event Code:

Go top
thisform.pageframe1.page1.text1.value= ""
thisform.pageframe1.page1.Text1.Setfocus
with Thisform.pageframe1.page1.grid1.
    width=290
    height=100
    left=0
    top=0
    . recordsource= "Web site information table "
    . visible=.t.
    readonly=.t..
    Columncount=3
    . column1.header1.caption= "Number"
    . Column1.header1.backcolor=rgb (255,255,190)
    . Column2.header1.backcolor=rgb (255,255,190)
    . column2.header1.caption= "website name"
    . Column3.header1.backcolor=rgb (255,255,190)
    . column3.header1.caption= "website url"
    . Column1.width=75
    . Column2.width=80
    . column3.width=150
endwith
thisform.pageframe1.page1.grid1.Setall ("Dynamicbackcolor", "RGB" (224,225,255 ) ", Column"
Thisform.pageframe1.page1.refresh

(iv) event code for each object in Page2 ("Add Record"):

1, Page2 Activate event code:

This.refresh

2, "Add" button Command1 Click event Code:

A=alltrim (Thisform.pageframe1.page2.Text1.value) B=alltrim (thisform.pageframe1.page2.Text2.value) C=alltrim ( 
Thisform.pageframe1.page2.Text3.value) if empty (b) && This condition indicates that the text box is empty messagebox ("Please enter site name", 16, "System Prompt") return else locate for Web name =b If. not.eof () && This condition is set up to add content and the table has duplicate go top MessageBox ("Do not allow duplicate site name", 16, " System Prompt ") Thisform.pageframe1.page2.Text1.setfocus return endif endif if empty (c) MessageBox (" Please enter Web site URL ", 16," department Locate for Web site =c If. not.eof () go to top MessageBox ("Do not allow duplicate site URLs", 16, "System hints") this
  Form.pageframe1.page2.Text1.setfocus return endif endif if Empty (a) =.f. Locate for number =a if. not.eof () go to top MessageBox ("Do not allow duplicate site numbers", 16, "system prompts") Thisform.pageframe1.page2.Tex T1.setfocus return Else Msg=messagebox (' Are you sure you want to add a record? ', 32+4, ' system hint ') if msg=6 append blank go bottom Replace Web site information table. Number with Alltrim (thisform.pageframe 1.page2. Text1. value),;
       Web site Information table-site name with Alltrim (Thisform.pageframe1.page2.Text2.value),; Site information table. Web site with Alltrim (thisform.pageframe1.page2.Text3.value) MessageBox (' Save record Success! ', 64, ' system hint ') thisform.pageframe1.page2.text1.value= "thisform.pageframe1.page2.text2.value=" "THISFO Rm.pageframe1.page2.text3.value= "" "Thisform.pageframe1.page2.refresh endif endif Else MessageBox (' Please enter the Web site's edit Resolution ', 16, ' system hint ') endif

3, "Exit" button Command2 Click event Code:

Msg=messagebox (' Are you sure you want to exit the system? ', 32+4, ' system hint ')
if msg=6
 thisform.release
endif

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.