Data Controls

The Data Controls tab provides 8 data-aware controls that bind directly to database fields and result sets. These controls automatically display, navigate, and edit database data without manual synchronization code.

TBrowse CT_BROWSE = 79

High-performance data grid for browsing and editing tabular data. Supports both database-bound and virtual (code block) modes. The most powerful data display control in HarbourBuilder.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component (TDBFTable, TSQLite, etc.)
aColsArray{}Array of TBrowseColumn objects
nRowCountNumeric0Number of visible rows (read-only)
nColCountNumeric0Number of columns (read-only)
nRowPosNumeric1Current row position in the visible area
nColPosNumeric1Current column position
lEditableLogical.F.Allow in-place cell editing
lVirtualLogical.F.Use virtual mode (data supplied via code blocks)
nVirtualRowsNumeric0Total row count in virtual mode
lShowHeadersLogical.T.Show column header row
lShowGridLogical.T.Show grid lines
lAlternateColorsLogical.F.Alternate row background colors
nClrRowOddColorinheritedOdd row background color
nClrRowEvenColorinheritedEven row background color
nClrSelectedColorsystemSelected row highlight color

TBrowseColumn Properties

PropertyTypeDefaultDescription
cHeadingString""Column header text
cFieldString""Database field name to bind
bBlockBlockNILCode block that returns cell value (virtual mode)
nWidthNumeric100Column width in pixels
nAlignNumeric0Alignment (0=left, 1=center, 2=right)
cPictureString""Display format picture clause
lEditableLogical.T.Allow editing this column

TBrowse Events

EventCategoryDescription
OnClickActionUser clicked a cell. Params: nRow, nCol
OnDblClickActionUser double-clicked a cell. Params: nRow, nCol
OnRowChangeNavigationCurrent row changed. Params: nOldRow, nNewRow
OnColChangeNavigationCurrent column changed. Params: nOldCol, nNewCol
OnHeaderClickActionColumn header clicked (for sorting). Params: nCol
OnBeforeEditEditBefore cell editing begins. Return .F. to cancel. Params: nRow, nCol
OnAfterEditEditAfter cell edit committed. Params: nRow, nCol, xOldValue, xNewValue
OnKeyDownKeyboardKey pressed while browse has focus. Params: nKey
OnPaintDisplayCustom cell painting. Params: nRow, nCol, oCanvas
OnVirtualDataDataRequest data for a virtual row. Params: nRow, nCol. Must return cell value
PlatformNative Widget
WindowsCustom owner-drawn ListView (WC_LISTVIEW)
macOSNSScrollView + NSTableView
LinuxGtkScrolledWindow + GtkTreeView

TDBGrid CT_DBGRID = 80

Simplified data grid that auto-generates columns from the data source fields. Easier to use than TBrowse when full customization is not needed.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component to bind
lAutoColumnsLogical.T.Automatically create columns from fields
lEditableLogical.F.Allow in-place editing
lSortableLogical.T.Allow sorting by clicking headers
EventCategoryDescription
OnClickActionCell clicked
OnDblClickActionCell double-clicked
OnRowChangeNavigationCurrent row changed
OnAfterEditEditCell edit committed

TDBNavigator CT_DBNAVIGATOR = 81

Navigation bar with buttons for first, previous, next, last, insert, delete, edit, save, and cancel operations on a data source.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component to navigate
lShowInsertLogical.T.Show Insert button
lShowDeleteLogical.T.Show Delete button
lShowEditLogical.T.Show Edit button
lConfirmDeleteLogical.T.Prompt before deleting a record
EventCategoryDescription
OnBeforeActionActionBefore a navigator action. Return .F. to cancel. Params: nAction
OnAfterActionActionAfter a navigator action completes. Params: nAction

TDBText CT_DBTEXT = 82

Data-aware label. Automatically displays the value of a bound database field as read-only text.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component
cFieldString""Field name to display
cPictureString""Display format picture clause

TDBEdit CT_DBEDIT = 83

Data-aware text input. Binds a TEdit control to a database field for viewing and editing.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component
cFieldString""Field name to bind
cPictureString""Input/display format picture clause
lReadOnlyLogical.F.Prevent editing
EventCategoryDescription
OnChangeActionField value changed by user
OnValidateValidationValidate before saving. Return .F. to reject. Params: xValue

TDBComboBox CT_DBCOMBOBOX = 84

Data-aware combo box. Displays a drop-down list bound to a database field. Useful for lookup fields.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component
cFieldString""Field name to bind
aItemsArray{}List of selectable items
oLookupSourceObjectNILOptional lookup data source for items
cLookupFieldString""Field from lookup source to display
cLookupKeyString""Key field from lookup source
EventCategoryDescription
OnChangeActionSelection changed

TDBCheckBox CT_DBCHECKBOX = 85

Data-aware check box. Binds a logical (boolean) database field to a check box control.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component
cFieldString""Logical field name to bind
cTextString""Label text beside the check box
xValueOnAny.T.Value representing checked state
xValueOffAny.F.Value representing unchecked state
EventCategoryDescription
OnChangeActionCheck state changed

TDBImage CT_DBIMAGE = 86

Data-aware image display. Shows an image stored in a database BLOB field or referenced by a file path field.

PropertyTypeDefaultDescription
oDataSourceObjectNILData Access component
cFieldString""BLOB or file path field name
lStretchLogical.F.Stretch image to fill the control
lProportionalLogical.T.Maintain aspect ratio when stretching
lIsPathLogical.F.Field contains a file path (not binary data)

Code Example: TBrowse with Database

// A data browsing form with TBrowse, navigator, and data-aware controls

FUNCTION Main()

   LOCAL oForm, oDB, oBrw, oNav

   // Create form
   oForm := TForm():New()
   oForm:cTitle := "Customer Browser"
   oForm:nWidth := 800
   oForm:nHeight := 500

   // Connect to database
   oDB := TSQLite():New()
   oDB:cFile := "customers.db"
   oDB:lAutoConnect := .T.

   // Create the browse control
   oBrw := TBrowse():New( oForm )
   oBrw:nLeft   := 10
   oBrw:nTop    := 10
   oBrw:nWidth  := 780
   oBrw:nHeight := 350
   oBrw:oDataSource := oDB
   oBrw:lAlternateColors := .T.

   // Define columns
   oBrw:AddColumn( "Id",    "id",    60,  2 )  // right-aligned
   oBrw:AddColumn( "Name",  "name",  200, 0 )  // left-aligned
   oBrw:AddColumn( "Email", "email", 250, 0 )
   oBrw:AddColumn( "City",  "city",  150, 0 )

   // Events
   oBrw:OnDblClick    := { |r,c| EditRecord( oDB, r ) }
   oBrw:OnHeaderClick := { |c| SortByColumn( oDB, oBrw, c ) }
   oBrw:OnRowChange   := { |o,n| UpdateStatus( n ) }

   // Add navigator bar
   oNav := TDBNavigator():New( oForm )
   oNav:nLeft := 10
   oNav:nTop  := 370
   oNav:oDataSource := oDB
   oNav:lConfirmDelete := .T.

   // Load data and activate
   oDB:Query( "SELECT * FROM customers ORDER BY name" )
   oForm:Activate()

RETURN NIL
8 Data Controls

Data controls automatically synchronize with their data source. When the user navigates to a different record, all bound controls update instantly. Changes are written back to the database when saved.

On This Page

TBrowse CT_BROWSE = 79 TDBGrid CT_DBGRID = 80 TDBNavigator CT_DBNAVIGATOR = 81 TDBText CT_DBTEXT = 82 TDBEdit CT_DBEDIT = 83 TDBComboBox CT_DBCOMBOBOX = 84 TDBCheckBox CT_DBCHECKBOX = 85 TDBImage CT_DBIMAGE = 86 Code Example: TBrowse with Database