this is a control that will display your data in a repeated sequence. unlike a normal grid, this control can show multiple lines from the same record, thus giving you the ability to display data in a scrollable container with no restriction on the number of fields to display. there are a number of examples of a datarepeater to be found but it is better to visualise it than to describe it, so here is my datarepeater control in action.

this control is very easy to setup and use as you will see. just a few steps and a few properties to set. so here goes.

because of the way classes are implemented in vfp you cannot add an object from a form, only from a class, therefore there is an additional step required for setting up this class.

open a new form, resize it and add a datarepeater object to it as shown below

the form above has the datarepeater control added to it. this is just a container into which you will place your fields. this control is databound so all controls dropped into it must also be databound.

the easiest way to add fields, is to open a table in the form de and drag and drop fields from there into the container. the table can be deleted from the de after you are done adding fields.

in the image below i have added fields from the customer table found in the \samples\data directory of vfp. notes field was added to show memos in action.

now re-arrange and resize the fields as well as resize the container as needed. once you are satisfied with the result, select the container and save it as a class – from the menu file|saveas class and save it into the bbdatarepeater class library. i have saved my class as customerdata.


the class instance along with the fields, can now be deleted from the form once you have saved it as a class..

next insert a datarepeatergrid object on the form. since i plan to have 2 panels of repeating data i need to make my form large enough to fit since the grid will expand at runtime to accommodate the 2 panels. this is dependant on the number of fields used since the larger the datarepeater with fields is, the larger will be the grid.

once that’s done it is now a matter of setting a few properties of the datarepeatergrid object.

the properties that need to be set are shown here as i have made them all favourites.

that is all. now the form is ready, so run it..

clicking on the buttons will fire the custom method buttonclicked and you can see that the class knows which record you are on.


download the class and a sample form from the link below.

enjoy.

4 Responses to A Visual Foxpro DataRepeater Class

  • Arjun D. Bagojikop says:

    Thanks Bernard
    Its a Cool!
    Before i have posted like this class on our Foxite
    http://www.foxite.com/archives/multi-objects-in-a-single-column-grid-0000185893.htm

    Sorry to disappoint you but your class uses a similar method is all. It is nothing like the functionality of this class.

    For instance, does your grid column resize automatically – height and width? There are so many differences that I won’t say more.

  • Arjun D. Bagojikop says:

    you Right Barnard

    if you resize a particular row its become very ultimate class

    when user got focus on particular row it will resize automatically as per control and he/she lost focus it will become normal

  • Anil says:

    Nice Class Bernard!. well arjun best part of

    bernard class is gui and the custom method

    which fired on click on red cross. other thing

    u have made the class Which use more resource

    in case of Bernard he used purely Grid this is

    grid’s other aspect which is i dont think that

    most of vfp guy’s know abt it.! my rating to u

    bernard!. Keep up your Good Work.

    Anil

     

  • Anil says:

    Bernard Look Grid.View Property 🙂
    That will inspire your for making new class
    use it with split.

Leave a Reply

Your email address will not be published. Required fields are marked *