JavaScript Editor js editor     Web development 

Main Page

File: ...\Samples\Solution\Controls\Pgframe\Pfsam1.scx

This sample illustrates using a page frame with tabs. The number of tabs changes dynamically when a user chooses a new value in a spinner. When the user selects a tab, a list box displays values specific to the tab.

To change the number of tabs at run time

  1. Set the PageCount property to the desired number of pages.

The list box in this sample is positioned on the form, not on any of the pages in the page frame. This placement makes it possible for you to have a single control visible in all of your pages.

Two user-defined form methods set the captions on the tabs and make sure the values in the list box match: UpdateList and SetCaption.

UpdateList Method

UpdateList is called when the number of tabs changes and when the user selects a new tab.

В Copy Code
LOCAL lnPage, lcHigh, lcLow
#define NO_MATCH_LOC 'No Matching Names for '
lnPage = THISFORM.pgfRolodex.activepage
THISFORM.aCustomers[1,1] = NO_MATCH_LOC + ;
THISFORM.aCustomers[1,2] = ""

lcHigh = substr(THISFORM.pgfrolodex.Pages(lnPage).caption,3,1)
lcLow = substr(THISFORM.pgfrolodex.Pages(lnPage).caption,1,1)
SELECT company, phone FROM customer;
   WHERE company <= lcHigh and company => lcLow;
   ORDER BY company;
THISFORM.lstCustomers.Value = 1

SetCaption Method

SetCaption is called in the spinner's UpClick and DownClick events to calculate what captions should appear on the tabs.

В Copy Code
THISFORM.LockScreen = .T.
FOR n = 1 to THISFORM.pgfRolodex.PageCount
   FirstLetter = SUBSTR(THISFORM.Alphabet,((n - 1)*ROUND(LEN(THISFORM.Alphabet)/THISFORM.pgfRolodex.PageCount,0))+1,1)
   IF n = THISFORM.pgfRolodex.PageCount   &&last page
      LastLetter = right(THISFORM.Alphabet,1)
      LastLetter = SUBSTR(THISFORM.Alphabet,((n)*ROUND(LEN(THISFORM.Alphabet)/THISFORM.pgfRolodex.PageCount,0)),1)
   THISFORM.pgfRolodex.Pages(n).Caption = FirstLetter + "-" + LastLetter
THISFORM.LockScreen = .F.

Alphabet is a user-defined form property that is used to determine the captions for each tab. To get the same functionality in different languages, set the Alphabet property to a string containing all the letters in the target language alphabet.

See Also

JavaScript Editor js editor     Web development