# GraffitiGrid
Class Inherits GraffitiUIControl
## About
GraffitiGrid is a fully-custom listbox control complete with custom cell types and events for drawing the most complex list of data you can dream up. Supports embedding controls and containers, custom row and header rendering, frozen columns, and much more.
## Preview
## Compatibility
### Framework API Version
| 1.0 | 2.0 |
| :---: | :---: |
| False | True |
### Console
| 32-Bit | 64-Bit |
| :---: | :---: |
| True | True |
### Desktop
| 32-Bit | 64-Bit |
| :---: | :---: |
| True | True |
### iOS
| 32-Bit | 64-Bit |
| :---: | :---: |
| False | True |
### Web
| 32-Bit | 64-Bit |
| :---: | :---: |
| True | True |
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| CellBorderTypes | None <br> Left <br> Right <br> Both | Supported cell border types. |
| RowBorderTypes | None <br> Top <br> Bottom <br> Both | Supported row border types. |
| SelectionTypes | Single <br> Multiple | Supported selection models. |
## Event Definitions
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| CellDrawBackground | g as Graphics <br> column as GraffitiGridColumn <br> row as GraffitiGridRow | Boolean | Raised when the cell background is being drawn. Return True to cancel default drawing. |
| CellDrawTreeDisclosure | g as Graphics <br> column as GraffitiGridColumn <br> row as GraffitiGridRow <br> disclosure as Picture <br> bounds as Xojo.Rect | Boolean | Raised when a disclosure is being drawn. |
| CellDrawTreeStructure | g as graphics <br> column as GraffitiGridColumn <br> row as GraffitiGridRow | Boolean | Raised when tree structure is being drawn. |
| CellDrawValue | g as Graphics <br> column as GraffitiGridColumn <br> row as GraffitiGridRow <br> isEditing as Boolean | Boolean | Raised when the cell value is being drawn. Return True to cancel default drawing. |
| CellPressed | column as GraffitiGridColumn <br> row as GraffitiGridRow | (None) | Raised when the user presses a cell. |
| CellValueChanged | column as GraffitiGridColumn <br> row as GraffitiGridRow | (None) | Raised when the user has changed the value of a cell by editing. |
| Closing | (None) | (None) | |
| ColumnSorted | column as GraffitiGridColumn | (None) | Raised after the Grid's rows have been sorted by pressing a column's header. |
| FooterCellDrawBackground | g as Graphics <br> column as GraffitiGridColumn | Boolean | Raised when a footer cell's background is being drawn. |
| FooterCellDrawText | g as Graphics <br> column as GraffitiGridColumn | Boolean | Raised when a footer cell's text is being drawn. |
| HeaderCellDrawBackground | g as Graphics <br> column as GraffitiGridColumn | Boolean | Raised when the specified column header is being drawn. Return True to cancel default drawing. |
| HeaderCellDrawText | g as Graphics <br> column as GraffitiGridColumn | Boolean | Raised when the specified column header is being drawn. Return True to cancel default drawing. |
| HeaderPressed | column as GraffitiGridColumn | Boolean | Raised when the user presses a column's header. Return True to cancel sorting if enabled. |
| Opening | (None) | (None) | |
| RowCollapsed | row as GraffitiGridRow | (None) | Raised when a row is collapsed. |
| RowDrawBackground | g as Graphics <br> row as GraffitiGridRow | Boolean | Raised when the background of a row is being drawn. Return True to cancel default drawing. |
| RowExpanded | row as GraffitiGridRow | (None) | Raised when a row is expanded. |
| ScrollPositionChanged | (None) | (None) | Raised when the user has scrolled the Grid by dragging. |
| SelectionChanged | (None) | (None) | Raised when the user has changed which row(s) within the Grid are selected. |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AddColumn | column as GraffitiGridColumn | (None) | Add the specified column. |
| AddColumnAt | index as Integer <br> column as GraffitiGridColumn | (None) | Add the specified column at the supplied index. |
| AddColumns | ParamArray columns() as GraffitiGridColumn | (None) | Adds the specified columns. |
| AddColumns | columns() as GraffitiGridColumn | (None) | Adds the specified columns. |
| AddRow | row as GraffitiGridRow | (None) | Adds the specified row. |
| AddRowAt | index as Integer <br> row as GraffitiGridRow | (None) | Adds the specified row at the supplied index. |
| AddRows | rows() as GraffitiGridRow | (None) | Adds the specified rows. |
| AddRows | ParamArray rows() as GraffitiGridRow | (None) | Adds the specified rows. |
| AddRows | rs as Rowset <br> indexColumnName as String = "row_id" | (None) | Adds the specified rows. |
| ColumnAt | index as Integer | GraffitiGridColumn | Returns the column at the specified index. |
| ColumnFromName | name as String | GraffitiGridColumn | Returns the column whose name matches the specified name. |
| DeselectAllRows | (None) | (None) | Deselects all rows in the Grid. |
| EditBegin | column as GraffitiGridColumn <br> row as GraffitiGridRow | (None) | Enters edit mode for the specified cell. |
| EditCancel | (None) | (None) | Cancels the current edit operation, if any. |
| EditCommit | (None) | (None) | Commits changes on any current edit operation, if any. |
| IndexOfColumn | column as GraffitiGridColumn | Integer | Returns the index of the supplied column. |
| IndexOfRow | row as GraffitiGridRow | Integer | Returns the index of the supplied row. |
| InvalidateAllRows | (None) | (None) | Signals that all rows should be redrawn then refreshes the display. |
| InvalidateHeader | (None) | (None) | Signals that all columns headers should be redrawn then refreshes the display. |
| InvalidateRow | row as GraffitiGridRow | (None) | Singals that the specified row should be redrawn then refreshes the display. |
| LastColumnIndex | (None) | Integer | Returns the index of the last column within the internal columns array. |
| LastRowIndex | (None) | Integer | Returns the index of the last row within the internal rows array. |
| RemoveAllColumns | (None) | (None) | Removes all columns from the Grid. |
| RemoveAllRows | (None) | (None) | Removes all rows from the Grid. |
| RemoveColumn | column as GraffitiGridColumn | (None) | Removes the specified column. |
| RemoveColumnAt | index as Integer | (None) | Removes the column at the specified index. |
| RemoveRow | row as GraffitiGridRow | (None) | Removes the specified row. |
| RemoveRowAt | index as Integer | (None) | Removes the row at the specified index. |
| RowAt | index as Integer | GraffitiGridRow | Returns the row at the specified index within the internal row array. |
| ScrollTo | column as GraffitiGridColumn <br> row as GraffitiGridRow | (None) | Scrolls to the specified location. Column or Row may be Nil, but not both. |
| ScrollTo | position as Point | (None) | Scrolls to the specified location. Column or Row may be Nil, but not both. |
| ScrollToBottom | (None) | (None) | Scrolls to the maximum Y position. |
| ScrollToTop | (None) | (None) | Scrolls to the minimum Y position. |
| SelectAllRows | (None) | (None) | Selects all currently added rows. |
| SelectedRows | (None) | GraffitiGridRow | Returns all currently selected rows. |
| Attributes | Hidden | UpdateProperty | |
| Attributes | Hidden | UpdatePropertyMultiple | |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| AllowDragReorderColumns | Boolean | False | Controls whether users may long-press and drag to reorder columns. |
| AllowDragReorderRows | Boolean | False | Controls whether users may long-press and drag to reorder rows. |
| BackgroundColor | ColorGroup | Nil | ColorGroup applied to the background of the Grid. |
| BorderColor | ColorGroup | Nil | ColorGroup applied to the outside edge of the Grid. |
| CellBorderColor | ColorGroup | Nil | ColorGroup applied to cell borders. |
| CellBorderType | GraffitiGrid.CellBorderTypes | Nil | Determines which borders to draw on cells. |
| CellPadding | Double | Nil | Inside cell spacing. |
| CurrentEditor | GraffitiGridCellEditor | Nil | Instance of the currently active cell editor. Only non-Nil during edit operations. |
| DatabaseRemoveRows | Boolean | False | When True and a row is removed from the Grid, the associated database row will be removed. |
| DatabaseUpdateRows | Boolean | False | When True and a row's data is changed, the associated database row will be updated. |
| DefaultRowHeight | Integer | Nil | Default row height. Overridden by individual GraffitiGridRow.Height properties. |
| Footer | GraffitiGridRow | Nil | Footer row drawn in the display. |
| FooterBackgroundColor | ColorGroup | Nil | Background color used to draw footer row. |
| FooterRowHeight | Integer | Nil | Height, in points, of the FooterRow. |
| FrozenBackgroundColor | ColorGroup | Nil | ColorGroup applied to the background of the left panel when there are frozen columns. |
| HeaderBackgroundColor | ColorGroup | Nil | ColorGroup applied to the background of the header row. |
| HeaderRowHeight | Double | Nil | Height of the header row. |
| IsEditable | Boolean | False | Controls whether users may double-press cells to edit them when an appropriate cell editor is available. |
| IsFooterVisible | Boolean | Nil | Controls visibility of the footer row. |
| IsHeaderVisible | Boolean | Nil | Controls whether the column header row is visible. |
| IsTreeView | Boolean | Nil | Controls whether the Grid treats data as a treeview and draws tree structure. |
| LockUpdate | Boolean | Nil | Controls whether redraw operations should be carried out as a result of changes to data or properties. Typically used to speed up data loading. |
| RowBorderColor | ColorGroup | Nil | ColorGroup applied to row borders. |
| RowBorderType | GraffitiGrid.RowBorderTypes | Nil | Determines which borders to draw on rows. |
| RowColorEven | ColorGroup | Nil | ColorGroup applied to the background of even-indexed rows. |
| RowColorOdd | ColorGroup | Nil | ColorGroup applied to the background odd-indexed rows. |
| ScrollMaximum | Point | Nil | Maximum X and Y scroll positions. |
| ScrollPosition | Point | Nil | Current X and Y scroll positions. Replace value to alter rather than altering properties of existing object. |
| SelectedRowColor | ColorGroup | Nil | ColorGroup applied to the background of selected rows. |
| SelectionType | GraffitiGrid.SelectionTypes | Nil | Controls how many rows may be selected by the user. When value is Multiple, taps alternate row selection. |
| TreeColumn | GraffitiGridColumn | Nil | The automatically generated column used for tree structure. |