The main thing to remember about a grid is that it is always tied to a specific table (or cursor). One of its main uses is to display data from the table, and optionally to allow users to edit that data.
To achieve that, you need to set a number of properties:
- RecordSourceType: Set to 1 (assuming that the table is already open).
- RecordSource: Set to the alias of the table.
- ColumnCount: Set to the number of columns you want in the grid (which is the same as the number of fields in the table that you want to display).
- ControlSource (this is a property of each column, not of the grid as a whole): Set it to the name of the field within the table.
Now, let me give you a couple of shortcuts for setting this up:
- If you are using the project manager, simply drag the table from the project window and drop it on your form. This will generate a grid that will be all nicely set up to display the table.
- Alternatively, add the table to data environment of the form. Now drag the entire table from the data environment and drop it on the form's surface. Again, that will give you a grid where you can view and edit the entire table.
- If you only want some of the fields from the table, add the table to the data environment, but this time multi-select the individual fields from the table. Again, drag these to the form.
That should get you started. Come back if you have any more detailed questions.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro tips, advice, training, consultancy
Custom software for your business