# GraffitiGrid
Class Inherits GraffitiSuite.BaseCanvas
## 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, and much more.
## Preview


Previous
Next
## Compatibility
### Framework API Version
| 1.0 | 2.0 |
| :---: | :---: |
| True | True |
### Desktop
| 32-Bit | 64-Bit |
| :---: | :---: |
| True | True |
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| SelectionModes | Single <br> Multiple | Supported selection modes. |
## Event Definitions
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| BeforeEdit | column as GraffitiGridColumn <br> row as GraffitiGridRow <br> bounds as Xojo.Rect | Boolean | Raised before an edit operation is set to begin. Return True to cancel. |
| CellClick | theRow as GraffitiGridRow <br> theColumn as GraffitiGridColumn | Boolean | Fired when the user clicks a cell. |
| CellDoubleClick | theRow as GraffitiGridRow <br> theColumn as GraffitiGridColumn | (None) | Fired when the user double-clicks a cell. |
| ColumnReorder | theColumn as GraffitiGridColumn <br> oldIndex as Integer <br> newIndex as Integer | (None) | Fires when the user drags a column to a new position |
| ColumnResize | theColumn as GraffitiGridColumn <br> newWidth as Integer | (None) | Fires when the user resizes a column |
| ContextClick | column as GraffitiGridColumn <br> row as GraffitiGridRow <br> x as Integer <br> y as Integer | (None) | Raised when the user right-clicks the control. Row will be Nil if context-clicking a header. |
| DrawCellBackground | theRow as GraffitiGridRow <br> theColumn as GraffitiGridColumn <br> g as Graphics | Boolean | This event is raised before a cell's background is drawn and provides the opportunity to override the class's behavior. Return True if you draw to the graphics property here. |
| DrawCellText | theRow as GraffitiGridRow <br> theColumn as GraffitiGridColumn <br> g as Graphics | Boolean | This event is raised before a cell's text is drawn and provides the opportunity to override the class's behavior. Return True if you draw to the graphics property here. |
| DrawHeaderBackground | theColumn as GraffitiGridColumn <br> g as Graphics | Boolean | This event is raised before a header's background is drawn and provides the opportunity to override the class's behavior. Return True if you draw to the graphics property here. |
| DrawHeaderText | theColumn as GraffitiGridColumn <br> g as Graphics | Boolean | This event is raised before a header's text is drawn and provides the opportunity to override the class's behavior. Return True if you draw to the graphics property here. |
| EditBegun | row as GraffitiGridRow <br> column as GraffitiGridColumn | (None) | Raised when an edit operation has been started and the UI is completely ready. |
| EditCanceled | row as GraffitiGridRow <br> column as GraffitiGridColumn | (None) | Raised when the user has canceled an edit operation. |
| EditCommitted | row as GraffitiGridRow <br> column as GraffitiGridColumn | (None) | Raised when the user has committed a change to the cell being edited. |
| EditKeyDown | key as String | Boolean | Raised when the user presses a key in the cell editor. Return True if handled. |
| FocusLost | (None) | (None) | |
| FormatCellValue | g as Graphics <br> theRow as GraffitiGridRow <br> theColumn as GraffitiGridColumn <br> theValue as Variant <br> byRef formattedValue as String | Boolean | This event allows you to change the look and content of the text that will be drawn to the cell. |
| HeaderClick | theColumn as GraffitiGridColumn | Boolean | Raised when the user clicks a header. Return True to cancel built-in functionality. |
| MouseMove | X as Integer <br> Y as Integer <br> Row as GraffitiGridRow <br> Column as GraffitiGridColumn | Boolean | This event is raised when the mouse is moved. |
| MouseWheel | x as Integer <br> y as Integer <br> deltaX as Integer <br> deltaY as Integer | Boolean | Raised when the user has attempted to scroll the display using the mouse wheel. Return True to cancel default scroll operations. |
| Opening | (None) | (None) | |
| RowClick | theRow as GraffitiGridRow | (None) | Raised when the user clicks a row. |
| RowDrop | StartIndex as Integer <br> EndIndex as Integer | (None) | Raised when the user moves a row in the display by dragging. |
| Scroll | (None) | (None) | Raised when the user scrolls the display. |
| SelectionChanged | (None) | (None) | Raised when the selection has changed. |
| Sorted | Column as GraffitiGridColumn | (None) | Raised when the user sorts a column. |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Sub | AddColumn | (None) | Adds a column to the grid. |
| Sub | AddRow | (None) | Adds a row to the grid. |
| Sub | AddRows | (None) | Adds the specified rows to the grid. |
| Function | Column | As | Returns the column at the specified index. |
| Function | ColumnCount | As | Returns the number of columns added to the Grid. |
| Sub | DeselectAllRows | (None) | Deselect all currently selected rows. |
| Sub | DeselectRow | (None) | Deselect a specific row. |
| Sub | DeselectRow | (None) | Deselect a specific row. |
| Sub | DrawCellBackground | (None) | Used to draw the default cell background. |
| Sub | DrawCellMenu | (None) | Used to draw the cell background for popup style cells. |
| Sub | DrawCellProgress | (None) | Used to draw the progress indicator for progress type cells. |
| Sub | DrawCellProgress_Mac | (None) | Used to draw the progress indicator for progress type cells. |
| Sub | DrawCellProgress_Win | (None) | Used to draw the progress indicator for progress type cells. |
| Sub | EditCancel | (None) | Cancel the current edit operation. |
| Sub | EditCell | (None) | Begin editing of the specified row. |
| Sub | EditCell | (None) | Begin editing of the specified row. |
| Sub | EditCommit | (None) | Commit the current edit operation. |
| Function | GetColumnByID | As | Search for a column with the ID of theID. |
| Function | GetColumnIndex | As | Search for the column index of the supplied column. |
| Function | GetColumnLeft | As | Get the X position of the supplied column. |
| Function | GetColumnLeft | As | Get the X position of the supplied column. |
| Function | GetColumnWidth | As | Get width of the supplied column. |
| Function | GetColumnWidth | As | Get width of the supplied column. |
| Function | GetRow | As | Retrieve the dictionary instance for the supplied row. |
| Function | GetRowByTag | As | Retrieve the dictionary instance that has a RowTag equal to theTag. |
| Function | GetRowIndex | As | Return the current index of the supplied row. |
| Function | GetRowTop | As | Get the Y position of the specified row. |
| Function | GetRowTop | As | Get the Y position of the specified row. |
| Sub | InsertColumn | (None) | Inserts a new column at atIndex. |
| Sub | InsertRow | (None) | Inserts a new row at atIndex. |
| Sub | InvalidateAllRows | (None) | Force all rows to redrawn, regardless of their previous state. |
| Sub | InvalidateRow | (None) | Force the row at atIndex to be redrawn, regardless of previous state. |
| Function | IsEditingCell | As | Returns a boolean indicating if the specified cell is currently being edited. |
| Function | IsRowSelected | As | Returns True if the specified row is currently selected. |
| Function | IsRowSelected | As | Returns True if the specified row is currently selected. |
| Function | ListIndex | As | Returns the currently selected row index. |
| Sub | MoveRow | (None) | Moves the row at the specified index to a new position. |
| Sub | RemoveAllRows | (None) | Removes all rows from the Grid. |
| Sub | RemoveColumn | (None) | Removes the specified column from the display. |
| Sub | RemoveColumn | (None) | Removes the specified column from the display. |
| Sub | RemoveRow | (None) | Remove the specified row. |
| Sub | RemoveRow | (None) | Remove the specified row. |
| Function | RowCount | As | Returns a count of all the rows in the Grid. |
| Function | RowTag | As | Retrieves the RowTag of the specified row. |
| Sub | RowTag | (None) | Retrieves the RowTag of the specified row. |
| Function | RowTag | As | Retrieves the RowTag of the specified row. |
| Sub | RowTag | (None) | Retrieves the RowTag of the specified row. |
| Sub | ScrollIntoView | (None) | Scrolls the specified row in to view. |
| Sub | ScrollIntoView | (None) | Scrolls the specified row in to view. |
| Sub | ScrollTo | (None) | Scrolls the display to the specified position. |
| Sub | SelectAllRows | (None) | Select all rows. |
| Function | SelectedRows | As | Returns an array containing the currently selected rows. |
| Sub | SelectRow | (None) | Select the specified row. |
| Sub | SelectRow | (None) | Select the specified row. |
| Function | ShowMenu | As | Shows a DesktopMenuItem at the specified cell. |
| Sub | SortData | (None) | Causes the grid to re-sort the data in the provided column. |
| Sub | UpdateCell | (None) | Update the cell value specified and redraw the row. |
| Sub | UpdateRows | (None) | Invalidate all rows, causing them to be redrawn. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| BackgroundColor | Color | Nil | The color applied to the background of the entire grid. |
| Border | Boolean | Nil | Draw a border around the grid. |
| BorderColor | Color | Nil | The color of the border. |
| CellBorder | Boolean | Nil | Border around cells. |
| ColumnResize | Boolean | Nil | Allow user to resize columns. |
| CursorIndex | Integer | Nil | Current position of navigation cursor within the grid, a row index. |
| CustomColors | Boolean | Nil | Draw using custom color properties. |
| DragReorder | Boolean | Nil | Allow user to reorder columns by dragging. |
| DragReorderRows | Boolean | Nil | Allow user to reorder rows by dragging. |
| EditField | DesktopTextArea | Nil | Control used for text editing operations. |
| EditingColumn | GraffitiGridColumn | Nil | Column of current edit operation. Nil if not currently editing. |
| EditingRow | GraffitiGridRow | Nil | Row of current edit operation. Nil is not currently editing. |
| GradientFills | Boolean | Nil | When true, the grid will use subtle gradients instead of solid colors to draw components. |
| HasScrollbars | Boolean | Nil | Determines whether scrollbars are displayed. |
| HeaderBorder | Boolean | Nil | When true, draw a border around all column headers. |
| HeaderColor | Color | Nil | Background color of the header items when not hovered. |
| HeaderDividerColor | Color | Nil | Color of border between column headers, as well as between the header and the viewport. |
| HeaderDividerLineSize | Integer | Nil | The width of the divider between column headers. |
| HeaderHeight | Integer | Nil | The height of the header row. |
| HeaderHoverColor | Color | Nil | The background color of the header when hovered. |
| HeaderHoverTextColor | Color | Nil | The text color of the header when hovered. |
| HeaderTextBold | Boolean | Nil | Font weight of the header text. |
| HeaderTextColor | Color | Nil | Text color of the headers. |
| HeaderTextFont | String | Nil | Font used to draw headers. |
| HeaderTextItalic | Boolean | Nil | Determines the obliqueness of the header text. |
| HeaderTextSize | Integer | Nil | Font size of headers. |
| HeaderTextUnderline | Boolean | Nil | Applies the underline text decoration. |
| LastDrawTime | Double | Nil | How long, in seconds, the last redraw took. |
| LockUpdate | Boolean | Nil | When true, the grid will not redraw while making changes. Set to false again to update display. |
| MinimumColumnWidth | Integer | Nil | The smallest a column can be. |
| Private | As | Nil | |
| Private | | GraffitiGridColumn | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | | Variant | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | | Dictionary | |
| Private | As | Nil | |
| Private | As | = | |
| Private | | GraffitiGridRow | |
| Private | | GraffitiGridRow | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | Nil | |
| Private | As | Nil | |
| Private | As | = | |
| Private | As | = | |
| Private | As | = | |
| Private | As | Nil | |
| Private | | Double | |
| Private | As | Nil | |
| RowColor | Color | Nil | Background color of even-numbered rows. |
| RowColorOdd | Color | Nil | Background color of odd-numbered rows. |
| RowDividerColor | Color | Nil | Color of the divider between rows. |
| RowDividerLineSize | Integer | Nil | Height of the divider between rows. |
| RowHeight | Integer | Nil | Height of rows. |
| RowHoverColor | Color | Nil | Background color of rows when mouse is over them. |
| RowHoverTextColor | Color | Nil | Foreground color of rows when mouse is over them. |
| RowSelectedColor | Color | Nil | Background color of rows when selected. |
| RowSelectedTextColor | Color | Nil | Foreground color of rows when selected. |
| RowTextBold | Boolean | Nil | Font weight of rows. |
| RowTextColor | Color | Nil | Text color of rows. |
| RowTextFont | String | Nil | Font used to display row text. |
| RowTextItalic | Boolean | Nil | Italicize row text. |
| RowTextSize | Integer | Nil | Size to draw text. |
| RowTextUnderline | Boolean | Nil | Text decoration. |
| ScrollbarHorizontal | DesktopScrollbar | Nil | The control that is used as a horizontal scrollbar. |
| ScrollbarVertical | DesktopScrollbar | Nil | The control that is used as a vertical scrollbar. |
| ScrollPositionX | Integer | Nil | Current horizontal scroll position. |
| ScrollPositionY | Integer | Nil | Current vertical scroll position. |
| SelectionMode | SelectionModes | Nil | Selection type. |
| SortIconColor | Color | Nil | Color applied to the sort icon. |
| SortIconHoverColor | Color | Nil | Color applied to the sort icon on mouse over. |
| SystemColors | Boolean | Nil | When True, attempts to match the colors and UI style used by the system. Dark mode adaptive. |
| WrapCellText | Boolean | Nil | When True, string values will wrap when too long to fit horizontally within their cell. |