TDBCombo

Source: source/classes/dbcombo.prg

Inherits from: TComboBox

TDBCombo is a database-aware ComboBox that displays values from a DBF field and can return a different value to the bound variable. It supports an incremental search as the user types, and can auto-populate its items from the database when no explicit array is provided.

Key DATA Members

DATATypeDescription
cAliasCharacterWorkarea alias for the database table (default: current alias)
cFldListCharacterField name whose values are displayed in the combo
cFldItemCharacterField name whose value is returned to the bound variable
aListArrayArray of display strings shown in the dropdown
aItemsArrayArray of return values corresponding to aList entries
cSearchKeyCharacterIncremental search buffer for keyboard navigation

Methods

MethodDescription
New( nRow, nCol, bSetGet, aItems, nW, nH, oWnd, nHelpId, bChange, bValid, nClrFore, nClrBack, lPixel, oFont, cMsg, lUpdate, bWhen, lDesign, acBitmaps, bDrawItem, cAlias, cFldItem, cFldList, aList, nHGet )Create a new DBF-aware ComboBox
ReDefine( nId, bSetGet, aItems, oWnd, ... )Redefine from a dialog resource
Fill()Populate aItems and aList from the database (called automatically on New/ReDefine if no explicit arrays given)
Refill()Re-read the database and repopulate the combo items
SetItems( aItems, aList, lChanged )Set display and return value arrays manually
Add( cItem, nAt, cList )Add an item to the combo at position nAt
Del( nAt )Delete item at position nAt
ListGet()Return the selected element of ::aList
KeyChar( nKey, nFlags )Incremental search keyboard handler
Update()Refresh the display from the current bound variable

Example: Combo Linked to Customer City Field

#include "FiveWin.ch"

function Main()

   local oWnd, oCombo, cCity := Space( 20 )

   use Customer shared new
   index on field->city to tmpCity

   DEFINE WINDOW oWnd TITLE "TDBCombo Demo" SIZE 400, 150

   @ 30, 30 DBCOMBO oCombo VAR cCity ;
      ITEMS FIELD->city ;
      OF oWnd ;
      SIZE 150, 120

   ACTIVATE WINDOW oWnd CENTERED

   use

return nil

Notes

See Also