共用方式為


Manipulating Multiple Rows of Data

Visual FoxPro provides a very powerful tool — the grid object — for displaying and manipulating multiple rows of data.

Using Grids

The grid is a container object. Just as a form set can contain forms, a grid can contain columns. In addition, the columns contain headers and controls, each with their own sets of properties, events, and methods, giving you a great deal of control over the elements of the grid.

Container Can contain
Grid Columns
Column Headers, controls

The Grid object makes it possible for you to present and manipulate rows and columns of data in a form or page. A particularly useful application of the Grid control is creating one-to-many forms, such as an invoice form.

To see examples of using grids

  1. Run Solution.app in the Visual FoxPro \Samples\Solution directory.
  2. In the tree view, click Controls, and then click Grid.

To add a Grid control to a form

  • In the Form Controls toolbar, choose the Grid button and drag to size in the Form window.

If you do not specify a RecordSource value for the grid and there is a table open in the current work area, the grid will display all the fields in that table.

Setting the Number of Columns in a Grid

One of the first properties you might want to set for the Grid control is the number of columns.

To set the number of columns in a grid

  1. Select the ColumnCount property in the Property and Methods list.
  2. In the Property box, type the number of columns you want.

If the ColumnCount property is set to - 1 (the default), the grid will contain, at run time, as many columns as there are fields in the table associated with the grid.

See Also

Enhancing Control Display | Manually Adjusting Grid Display at Design Time | Using Controls | Setting the Source of the Data Displayed in the Grid | Controls and Objects