SGrid 2.0
The following categories are described:
- Columns
- Rows
- Cells
- Individual Properties and Methods
- The cGridCell object
- State: Edit Cell, Hot Cell and Selections
- Sorting
- Grid Settings and Options
- Image Lists
- Hierarchical Grouping
- Appearance
- Behaviour
- General
- Events
- Persistence
SGrid is designed to operate with a fixed number of columns. For performance
it is always better to add columns prior to adding any rows, making columns
invisible if you want to. There are two types of columns:
- Standard Columns
Standard columns appear in the header of the control and render from left to
right. These columns may be made invisible, re-ordered and grouped hierarchically.
- Optional Row-Text Column
The row-text column is used to display text and/or icons which stretch
across multiple columns in the grid. The Row-Text column renders
below the standard columns. If you are using one, the row-text column
must always be the last column in the grid. Whether the Row-Text column's
text appears will depend upon the height of the row that it appears in.
Note when you use the
hierarchical grouping option SGrid internally uses
a row-text column to render the group. The Grid will automatically add
this if it doesn't exist, but for performance you may want to add one
up-front.
Manipulating columns is achieved through the following properties and methods:
- AddColumn -
Adds or inserts a new column. For performance, it is best to set up columns before adding any data.
- To make invisible whilst adding a Column use .AddColumn sKey, sHeader, , , 0, bVisible:=False, esorttype:=CCLSortString
- RemoveColumn
-
Permanently removes a column from the grid. If all columns are removed,
the grid will be cleared. If you want to temporarily remove a column,
use the ColumnVisible
property.
- Columns -
Gets the number of columns in the grid, including hidden and RowText columns.
- ColumnIndex -
Gets the index of the column with the specified key.
- ColumnOrder -
Gets/sets the order of a column in the control.
- ColumnImage -
Gets/sets the image index to show in a column's header. Image indexes are 0 based indexes of the images in an ImageList.
- ColumnImageOnRight -
Gets/sets whether images (if any) will be shown on the right or not in a column header.
- ColumnImageOnRight -
Gets/sets whether images (if any) will be shown on the right or not in a column header.
- ColumnAlign -
Gets/sets the alignment used to draw the column header for a column.
- ColumnIsGrouped -
Gets/sets whether the specified column is grouped in the control. Setting to True causes the column to be added to the end of any existing groups.
- ColumnGroupOrder -
Gets the order the column appears at in the column grouping. If the column is not grouped, then returns 0.
- ColumnFormatString -
Gets/sets a format string used to format all of the text in the column (remember that
cell text is stored as a variant). Format strings are the same as those used in the
VB Format$ function.
- ColumnFixedWidth -
Gets/sets whether the specified column has fixed width or not.
- ColumnHeader -
Gets/sets the text to appear in a column header.
- ColumnKey -
Gets/sets the key for column.
- ColumnTag - Gets/sets an optional string value to associate
with the column.
- ColumnSortType -
A convenience property to use to maintain the the current column sort type.
- ColumnSortOrder -
A convenience property to use to maintain the the current column sort order.
- ColumnWidth -
Gets/sets the width of a column in the grid.
- ColumnIsRowTextColumn -
Gets whether this column is the row text column for the grid. The row text column
must be the last column in the grid.
- AutoWidthColumn -
Automatically resizes a column to accommodate the largest item.
Rows can be added, inserted to the grid, or removed or made invisible. If you can
add rows in order, you can choose to have SGrid pre-allocate a number of rows for you,
rather than adding each one individually, which can improve performance. To do this,
set the Rows property to the number of rows that you want.
There are two types of rows: standard rows and group rows. Group rows appear when
you create a hierarchical grouping in the grid, and have the RowIsGroup
property set to True. Note you cannot insert grouping rows
directly without setting up a grouping using one of the hierarchical grouping methods.
Note also that although you can change the properties of grouping rows using things like
the RowVisible property, this will in general prevent
correct operation of expand and collapse of groups. You should also only add rows to the
end of the grid and use the ShiftLastRowToSortLocation
method to ensure the correct position of the new row.
Cells may either be changed using individual properties or by using a cGridCell object.
The grid cell object is a disconnected object that represents a single cell. You can
either obtain a new cell object to assign to the grid using the NewGridCellFormatObject or obtain one pre-populated with existing cell
details using the Cell property. To assign any changes
back to the grid, use the Cell property to set it back
again. The object itself contains all of the information in the individual cell
properties.
SGrid 2.0 can be editable, track cells with the mouse and select either individual
cells or entire rows. These properties and methods allow you to configure these modes and
determine information about the current state.
Sorting is configured using SGrid's SortObject. This object
maintains details of both the currently hierarchical grouping state and non-grouped
sort for any row. You can have any number of columns in the sort, and each one can
be configured for the type of data and order you want to sort in. These methods are
exposed by the grid for sorting:
The cGridSortObject allows you to configure the sort you wish to
apply. For each sort column, you specify the SortColumn,
SortOrder and SortType properties. To
add a new column to the sort, set the index of the sort item to one greater than the
current sort count.
Up to two image lists can be associated with the control; one for the main grid and one for the
header. If you do not define a separate ImageList for the header then the control will assume
that the main ImageList should be used.
Grid data can be persisted and reloaded very quickly using
the SaveGridData
and LoadGridData methods. These methods only persist the cell
data and row information, so the data must be subsequently re-loaded into a grid with
the exact same column structure.
|
|