.section Widgets
.topic widget.dbgrid
.title DbGrid
.toc 0 DbGrid
.index DbGrid
.index wgtDbGrid
.index wgtDbGridSetDataWidget
.index Database Grid

.h2 DbGrid

A database grid widget that displays all records from a Data control in a scrollable, sortable table. Columns auto-populate from the Data control's column names and can be hidden, resized, and renamed by the application. Clicking a column header sorts the display. Selecting a row syncs the Data control's cursor position. The grid reads directly from the Data control's cached rows, so there is no separate copy of the data.

Header: widgets/widgetDbGrid.h

.h3 Creation

.code
WidgetT *grid = wgtDbGrid(parent);
wgtDbGridSetDataWidget(grid, dataCtrl);
.endcode

.h3 Macros

.index wgtDbGridRefresh
.index wgtDbGridSetColumnVisible
.index wgtDbGridSetColumnHeader
.index wgtDbGridSetColumnWidth
.index wgtDbGridGetSelectedRow

.table
  Macro                                                  Description
  -----                                                  -----------
  wgtDbGrid(parent)                                      Create a database grid widget.
  wgtDbGridSetDataWidget(w, dataWidget)                  Bind the grid to a Data control. The grid reads rows from this widget.
  wgtDbGridRefresh(w)                                    Re-read the Data control's state and repaint the grid.
  wgtDbGridSetColumnVisible(w, fieldName, visible)       Show or hide a column by field name.
  wgtDbGridSetColumnHeader(w, fieldName, header)         Set a display header for a column (overrides the field name).
  wgtDbGridSetColumnWidth(w, fieldName, width)           Set the width of a column by field name (tagged size, 0 = auto).
  wgtDbGridGetSelectedRow(w)                             Get the index of the currently selected data row (-1 if none).
.endtable

.h3 Properties (BASIC Interface)

.table
  Property     Type       Access       Description
  --------     ----       ------       -----------
  GridLines    Boolean    Read/Write   Whether to draw grid lines between cells.
.endtable

.h3 Methods (BASIC Interface)

.table
  Method       Description
  ------       -----------
  Refresh      Re-read the Data control and repaint.
.endtable

.h3 Events

.table
  Event        Description
  -----        -----------
  Click        Fires when a row is clicked.
  DblClick     Fires when a row is double-clicked. Default event.
.endtable
