Description


The component is used to show/select the record.



Class: TdbComboBox



Properties

 Property

 Type

 Description

 sqlValue

 String

  Returns the id of the selected record in the component, for use in SQL queries. In case of empty value, it returns NULL string

 example: SQLExecute ('INSERT INTO tablename (fieldname) VALUES ('+Form1.ComboBox1.sqlValue+')');

 dbItemID

 Integer

 The identifier of the selected record in the component. The identifier corresponds to the id field in the database. If no entry is selected, returns -1

 dbSortField

 String

 The database field by which the records in the component will be sorted.

 dbSortAsc

 Boolean

 If True, the records will be sorted in ascending order, otherwise in descending order.

 dbFilter

 String

 Allows you to set an additional filter that will be used to fill the component with data from the database. For example: tablename.fieldname = 1

 dbForeignKey

 String

 Specifies which external key of the database table this component belongs to.

 dbField

 String

 Determines which field of the database table this component belongs to.

 dbIncremSearch

 String

 Allows you to specify the name of the button on the current form with the "Search" or "SQL query" action, which will be automatically pressed when user changes the value of the component. The property is necessary to implement instant search.

 dbSQL

 String

 Contains the SQL query that was used when the SQLExecute method was called.

 CanFocus

 Boolean

  It checks if the component can get input focus, which is usually necessary before using the SetFocus method. If a component has Visible = False or Enabled = False property, or if the component is located on a parent component with those properties, using the SetFocus method will cause an error.


example: if Form1.ComboBox1.CanFocus then Form1.ComboBox1.SetFocus;

 Color

 TColor

 Specifies the background color of the control. More info.

 Cursor

 TCursor

 Specifies the image used to represent the mouse pointer when it passes into the region covered by the control. More info.

 DroppedDown

 Boolean

 Indicates whether the drop-down list is currently displayed.

 Enabled

 Boolean

 Controls whether the component responds to mouse, keyboard, and timer events.

 Focused

 Boolean

 Determines whether the control has input focus.

 Font

 TFont

 Allows you to set font name, size, color and style. More info.

 GetCount

 Integer

 Allows you to get the number of records in a component.

 HideTextIfNotExists

 Boolean

 Makes sense if the Searchable property = True. Set HideTextIfNotExists = False, so that the entered text will not disappear if it is not found among records.

 Hint

 String

 Hint contains the text string that appears when the user moves the mouse over the component., see also ShowHint

 ItemIndex

 Integer

 Specifies the index of the selected item. The first item in the list has index 0, the second item has index 1, and so on. If no item is selected, the value of ItemIndex is -1.

 Items

 TStringList

 Provides access to the list of items (strings) in the list portion of the combo box. More info.

 Items[i]

 String

 Line-by-line access to the list of records. Example: ShowMessage(Form1.ComboBox1.Items[1]); // will show a message with the second line (numbering from zero

 ItemsChecked[i]

 Boolean

 Makes sense if the MultiSelect = True property allows you to read or check the checkbox next to the record.

 MultiSelect

 Boolean

 Enables multiple selection of records in the component. Applies when using the button with the "Search" action or a script.

 Name

 String

 The name of the component.

 ShowHint

 Boolean

 Specifies whether to show the Help Hint when the mouse pointer moves over the component, see also Hint

 SearchableType

 TSearchType'

 It makes sense if the Searchable property = True. Search Type. Values: stExact - search for full match, stContain - search for substring in string.

 SelectedCount

 Integer

 Makes sense if the MultiSelect property = True. Returns the number of selected records in the component.

 SelLength

 Integer

 Specifies the length, in characters, of the selected text in the edit portion of the combo box.

 SelStart

 Integer

 Specifies the position of the first selected character in the edit portion of the combo box.

 Sorted

 Boolean

 Determines whether the records in the component will be sorted. By default, sorting is performed on the database field specified in the dbField property, you can change the field to be used for sorting using the dbSortField property. You can define the type of sorting in the dbSortAsc property.

 TabOrder

 Integer

 Indicates the position of the component in its parent's tab order. TabOrder is the order in which child components are visited when the user presses the Tab key.

 TabStop

 Boolean

 Determines whether the user can tab to a control. Use the TabStop to allow or disallow access to the control using the Tab key.

 Tag

 Integer

 Allows you to assign a number to a component for your own needs.

 TagString

 String

 Allows you to assign a string to a component for your own needs.

 Text

 String

 Contains a text string associated with the component.

 TextHint

 String

 Specifies the text that is displayed as a text watermark in the edit box of the combo box control.

 Visible

 Boolean

 Specifies whether the component appears onscreen.

 Left

 Integer

 Specifies the horizontal coordinate of the left edge of a component relative to its parent.

 Top

 Integer

 Specifies the vertical coordinate of the upper-left of a component relative to its parent.

 Width

 Integer

 Specifies the horizontal size of the component in pixels.

 Height

 Integer

 Specifies the vertical size of the component in pixels.




Methods

 Method

 Description

 procedure dbAddRecord (id: integer; text: string)

 Adds a record to the component and assigns it the specified id. The record will not be added to the database.

 procedure dbEditRecord (id: integer; text: string)

 Edits the record in the component with the specified id. The database record will not be edited.

 procedure dbDeleteRecord (id: integer)

 Deletes the record from the component with the specified id. The record will not be deleted from the database.

 function dbGetFieldValue (FieldName: string): variant

 The function allows you to get the value of the specified field from the database for the selected record in the component. If no record is selected in the component, the function returns Unassigned.

 function dbIndexToID (index: integer): integer

 The function allows you to get the id of a record by specifying its sequence number in the list.

 procedure dbSQLExecute (sql: string)

 The procedure allows you to fill a component with data from the database using an SQL query. The specified SQL query will be saved in the dbSQL property.

 procedure dbUpdate

 Forces the data in the component to be updated. Usually the component updates the data automatically if the data has been changed.

 procedure Clear

 Clears the contents of the component.

 procedure DoOnChange

 Forcibly executes the OnChange event if it was defined for a component.

 procedure SetAllCheckBoxes (const Checked: boolean)

 It makes sense if the MultiSelect property = True. Changes the state of the checkbox for each record.

 procedure SetFocus

 Gives the input focus to the component.




Events

 Event

 Description

 OnChange

 Occurs when the user changes the text displayed in the edit region.

 OnClick

 Occurs when the user clicks the component.

 OnCloseUp

 Occurs when the drop-down list closes up due to some user action.

 OnDoubleClick

 Occurs when the user double-clicks the left mouse button when the mouse pointer is over the component.

 OnDropDown

 Occurs when the drop-down list closes up due to some user action.

 OnEnter

 Occurs when a component receives the input focus.

 OnExit

 Occurs when the input focus shifts away from one component to another.

 OnKeyDown

 Occurs when a user presses any key while the form has focus.

 OnKeyPress

 Occurs when a key is pressed. Note that this procedure handles printable characters only.

 OnKeyUp

 Occurs when the user releases a key that was pressed.

 OnMouseEnter

 Occurs when the user moves the mouse into a component.

 OnMouseLeave

 Occurs when the user moves the mouse outside of a component.

 OnDropFiles

 Occurs when user tries to drag and drop a file from explorer to a form. More info.