Class | Package: cg | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Moderately revised from 8.2. 8.2 version

## class-grid

A `class-grid` is a specialized `grid-widget` subclass that makes it easier to create grids that edit instances of classes. Rather than defining row and column classes and then instantiating those classes and adding them to a `grid-widget`, you instead specify a single expression that parametrically describes the slots to be edited, and then the `class-grid` will automatically create grid columns for those slots. It will also automatically create grid rows for a set of instances when you set its value property to be a list of instances.

A `class-grid` always has a single body section with other sections for column and row headers, and there are other limitations to the style of the grid. In exchange for those limitations, a `class-grid` is much easier to set up than a general `grid-widget`.

## Using a Class-Grid

To use a `class-grid`, there are three main properties that you need to set:

- The edited-class property: set it to the name of the class whose instances the grid will display and/or edit.
- The edited-slots property: set it to an association list of slot names with parameters that specify what sort of value is in each slot and how they should be edited in the grid. This will make a `grid-column` for each specified slot, and is the biggest step in creating a `class-grid`. See edited-slots for a full description of the format of this value. If a `class-grid` is on a form window in an IDE Project, then you can specify this large value interactively by using the IDE's Class Interface Editor dialog.
- The value property: set it to be a list of instances of the edited-class. This will make a `grid-row` for each instance. Alternately you can call add-class-grid-row to add each row individually. Changing the list of instances in the value property in either of these ways will also cause the widget's on-change function to be run for user side effects.

## Other Class-Grid Properties

A `class-grid` has all of the properties of a `grid-widget`, but you shouldn't set the column-sections and row-sections properties because they are created automatically from the edited-slots property. Since you cannot specify properties of a `class-grid`'s sections and subsections directly at creation time, some high-level properties are defined on the `class-grid` class itself that will affect its subobjects. These properties include:

- row-header-font
- column-header-font
- body-row-height
- default-column-width
- row-header-width
- column-header-height
- row-header-justification
- row-header-value-type
- rows-are-movable
- rows-are-resizable
- rows-are-selectable
- horizontally-scrollable

To reject invalid slot values as soon as the user enters them, write one or more validate-edited-slot-value methods.

For advanced use, after a `class-grid` has been created you could find the automatically created column and row sections and their subsections and modify them as with any other `grid-widget`. To do so, you may want to know that the two column-sections are named `:header` and `:body` (in that order), and so are the two row-sections. The single subsection of each header section is also named `:header`. The name of each column in the body is the name of the slot that it edits.

See also `class-grid-top-pane` and `class-grid-drawing-pane`.

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 8.2 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Moderately revised from 8.2. 8.2 version