Pages, PageCount

Pages is an array that gives you access to each page in a page frame without needing to know the page's name. PageCount tells you how many pages are in the page frame.

Usage

pgfPageFrame.PageCount = nNumberOfPages
nNumberOfPages = pgfPageFrame.PageCount
pagPage = pgfPageFrame.Pages[ nPageNumber ]
Pages is a collection property—an array that gives you access to all the objects in a container—in this case, pages in a page frame. PageCount tells the number of elements in Pages. You can change PageCount, which adds or removes pages in the page frame. Be careful about decreasing PageCount. The controls on the extra pages simply fall off into the bit bucket, never to be seen again.You also need to be careful about which pages disappear when you make PageCount lower. This is controlled not by the page order in Pages, but by the PageOrder property. If you make PageCount smaller than the current number of pages, those pages whose PageOrder is greater than the new PageCount are discarded.Starting in VFP 7, page frames also have an Objects collection, as do all the other container objects.

Example

* Count the total number of controls in a PageFrame
* Assume the PageFrame is PageFrame1 on the current form
LOCAL nPage, nTotalControls
nTotalControls=0
FOR nPage = 1 TO ThisForm.PageFrame1.PageCount
   nTotalControls = nTotalControls + ;
      ThisForm.PageFrame1.Pages[nPage].ControlCount
ENDFOR
 
* In VFP 5 and later, you can do this with a FOR EACH loop 
* instead. Note that the code in the loop is more readable.
LOCAL nTotalControls, oPage
nTotalControls=0
FOR EACH oPage IN ThisForm.PageFrame1.Pages
   nTotalControls = nTotalControls + oPage.ControlCount
ENDFOR

See Also

ControlCount, Controls, Objects, PageOrder


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .