| 
               
                VFP Tutorial - Navigation
  All the basic controls are available on the FoxPro Form Controls toolbar. This
  is shown docked above the Form Designer but can be dragged or docked 
  anywhere on the desktop. 
 
  The FoxPro toolbar looks familiar but there are subtle differences between 
  it and the equivalent toolbars in Access and Visual Basic. To add a 
  control to the form you click once on the toolbar then once on the form. 
  This will add the control to the form at its default size. You can click 
  on the toolbar then click on the form and drag the control to a new size 
  but it's easier to get the control onto the form in one operation and 
  adjust the size later.
 
  Don't try to drag a control from the toolbar to the form. Nothing will 
  happen.
 
Add a Close button
  Click on the button control (fifth button from the left) on the toolbar 
  and drop it on the bottom right of the form. Double-click on the button to 
  open an editor on the code that will run when the button is clicked. Type 
  this line of code into that window:
 
  ThisForm.Release
 
  ThisForm is the FoxPro equivalent of 
  Me 
  in Access and refers to the form which holds this object. As you type the 
  period a list of possible methods will appear. By the time that you have 
  typed 'rel' Fox will have identified that you want the 
  Release 
  method and will pop up a tooltip to identify it. Press 
   to confirm.
 
 
  Close and save the code window by pressing 
   or 
  by clicking the 
   button on the toolbar. Then press 
   
  or the exclamation mark on the toolbar to run the form.
 
   
 
  Click the button and the form will close and return you to the Form 
  Designer. The caption on the button is not quite right and we will correct 
  this by changing the Caption property of the button. Right-click on the 
  button and select 
   from the menu. 
 
Control properties
  FoxPro is a flexible object-oriented system with a wide range of 
  properties. You can reduce the number displayed so that you only see those 
  which have been changed from their default values. Right-click on the name 
  'Command1' at the top of the Properties Window and select  from
  the menu. This will filter the list to just the seven properties shown. 
 
  Click on the Caption property and type Close as a new value. Note that you 
  cannot type where the value is shown in the list, you have to type the new 
  value of the property into the textbox above.      
 
 
  Whilst you are in the Properties Window you can also change the name of 
  the control from its default value of "Command1" to something more 
  informative. You can see amongst the properties that the Click event holds 
  a 'User Procedure'. This code is part of the object and will still be a 
  part of the object if you change the  object's name. Visual FoxPro does 
  not suffer from the problem that Access and Basic have where changing the 
  name of a property breaks the link to its methods and leaves you with an 
  orphan.       
 
Navigation buttons
  Follow the same technique to add two more buttons to the form and change 
  their Caption properties to read 'Prev' and 'Next'. Double-click on the 
  'Prev' button and type this code into its Click event:       
 
  
   
  Skip -1
   
  ThisForm.Refresh
 
  The code in green is a comment. If a line starts with an asterisk then 
  everything on that line becomes a comment and is ignored by the compiler.
 
  Close the edit window, double-click on the 'Next' button
  and type this very similar code into its Click event:
 
  
   
  Skip 1
   
  ThisForm.Refresh
 
  Add two more buttons to go to the first and the last record. The FoxPro 
  commands are:
 
  
   
  Go Top
   
  ThisForm.Refresh
 
  and
   
  
   
  Go Bottom
   
  ThisForm.Refresh
 
  These four buttons are so similar that we would be thinking about 
  subclassing them all from the same source in a real system. 
 
Run the form    
  Click the red exclamation mark on the toolbar or select 
   from the  menu. 
 
 
Improve the navigation 
  These navigation buttons are too simple to be useful in real life. They 
  need extra code to prevent you trying to move to a position before the 
  first record or after the last record. Go to this page to learn more about 
  FoxPro
  
    program code
  . 
 
 
  Introduction |
  Environment |
  Project |
  Tables |
  Forms |
  Navigation |
  Executable
 
             |