The ComboBox control is frequently used when the user must input information which is chosen from a predetermined list.

combobox32.png Key properties: Data Field, Items, Lookup Data Source, Lookup Data Field, Lookup Text Field, Lookup Max Records
Key events: On Click, On Change
Server Code: ComboBox = Class(ButtonEditor)
Browser Code: ComboBox = Class(ButtonEditor)


Graphical States

States Appearance Description
Normal combobox-normal.png The default state for the control when no other state is active.
Mouseover combobox-mouseover.png This view is displayed when the user moves the cursor over the control
Focused combobox-focused.png This view is displayed when the control's ability to receive input is disabled.
Disabled combobox-disabled.png This view is displayed when the control's ability to receive input is disabled.


Learn more about Morfik Styles and Themes.

Layout

Combobox.jpg
'

Properties

Property Description
Auto Complete

When enabled, a Combobox will automatically insert an entry from its lookup list that best matches the text that is being typed in.

Auto Complete Delay

This property determines the amount of delay in milliseconds after a key is depressed before the auto-complete behavior of a Combobox is activated.

Auto Drop Down

When enabled, the list within a Combobox is automatically displayed as soon as a key is pressed.

Auto Filter

When enabled, the list within a Combobox is automatically filtered to only show the entries that match the text that is being typed in.

Border Color The BorderColor property specifies the color that should be used for drawing a rectangular border around the Control. Note: the border will not be visible unless the BorderStyle and BorderWidth properties are also set.
Border Sides The BorderSides property specifies the parts of a control's border that are displayed.
Border Style The BorderStyle property of the control defines how and if a border will be drawn around the control.
Border width The Border Width property specifies the line width used to draw the rectangular border around the Control. Note: the border will not be visible unless the BorderColor and BorderStyle properties are also set.
Color The Color property specifies the background color of the Control.
Cursor The Cursor property, if set, causes the appearance of the mouse cursor to change as it moves over the Control.
Data Field The DataField property is used to bind the Control to a database field. Either through a table or a query which is specified through the DataSource property of the Form that contains the control.
Enabled If the Enabled property is set to false, the Control's state or value cannot be changed by the user.

Note For Timer Control: This property controls whether the Timer event will be triggered at the time interval specified in the Interval property. If the Enabled property is set to false, the Timer event will not be triggered.

Font The Font property (and its sub-properties Color and Name) is used to indicate which font should be used for drawing the text in the Control.
Height The Height property specifies the vertical extent of the Control. Note: if the CanGrow or CanShrink properties are set, the actual height of the Control at run time may be different.
Hint The Hint property, if set, specifies the text of a tooltip that is displayed when the user moves the cursor over the control.
Horizontal Placement The HorizontalPlacement property, if set, governs how the Control adjusts its size and position in response to changes in the horizontal dimensions of its parent.
Item Index The ItemIndex property specifies the index of the selected item in the items list.
Items The Items property of the Control contains a list of strings with the values which will be displayed in the drop down list, if the choices will be a fixed.
Left The Left property specifies the horizontal position of the Control in the form.
Lookup Data Field The LookupDataField property identifies which field from the LookupDataSource the ComboBox will retrieve its reference data.
Lookup Data Source The LookupDataSource property identifies the data source (table or query) from which the ComboBox will retrieve its reference and display information.
Lookup Max Records The LookupMaxRecords property of the ComboBox defines how many records will be fetched from the LookupDataSource.
Lookup Text Field The LookupTextField property identifies which field from the LookupDataSource the ComboBox will retrieve its display data.
Margins The Margins property clears an area around control (outside its border).
Name The Name property specifies the identifier used to reference the control from browser- or server-side code.
Opacity The Opacity property determines the extent to which the Control obscures any controls placed in its background. A value of 0 means that background controls are fully visible, whereas a value of 100 means that background controls are completely obscured.
Shared Style The SharedStyle property can be used to force several controls always have the same appearance.
Sorted The Sorted property indicates whether the Items list is sorted.
Style The Style property determines if the user can can type any value in the editable area of the ComboBox, or if only values from the list can be selected.
Tab Order The TabOrder property allows the developer to specify the order in which controls should receive input focus when the user steps through them using the tab key.
Tag The Tag property is used to store user data that is associated with the control.
Text The Text property for the control allows direct access for setting or reading the text that is currently in the control. This property can be bound to a database table field as to automatically display its contents and allow editing of them.
Top The Top property specifies the vertical position of the Control in the form.
Vertical Placement The VerticalPlacement property, if set, governs how the Rectangle adjusts its size and position in response to changes in the vertical dimensions of its parent.
Visible The visible property is used to make controls visible or invisible. Invisible controls are frequently used to allow for easy access to information from a database table field, if the control is bound to one.
Width The Width property specifies the horizontal extent of the Form/control.

Events (browser-side)

Event Description
On Blur Event This event is fired within the browser when a control loses focus either by the pointing device or by tabbing navigation.
On Change This event is fired within the browser after the text in the control was changed by the user. Note: this event is not fired until the control loses keyboard focus.
On Click The most commonly used event for a TextLabel control is the OnClick event, which should be handled to execute whatever action is intended when a control is clicked.
On Double Click This event is fired when the user clicks on a control within the browser.
On Focus This event is fired within the browser when a control receives focus either by the pointing device or by tabbing navigation.
On Key Down This event is fired within the browser when a key is pressed down.
On Key Up This event is fired within the browser when a key is released.
On Mouse Down This event is fired within the browser when the mouse button, or any other pointing device button, is pressed while it is over a control. On a PC-based mouse, it specifically relates to the left-hand mouse button being depressed.
On Mouse Out This event is fired when the mouse pointer, or any other pointing device button, is moved out of the region defined by a control.
On Mouse Over This event is fired when the mouse pointer or any other pointing device is over (within the region defined by) a control.
On Mouse Up This event is fired within the browser when the mouse button, or any other pointing device button, is released over a control. On a PC-based mouse, it specifically relates to when the left-hand mouse button is being released.
On After Pushed Or Pulled This event is fired within the browser after the position of a control has changed in response to a change in the content of a sibling control.
On Before Pushed Or Pulled This event is fired within the browser before the position of a control is changed in response to a change in the content of a sibling control.

   

Events (server-side)

Event Description
On After Print This event is fired on the server by a Control after its HTML (or in the case of Report generation, PDF) content is generated.
On Before Print This event is fired by a control on the server before control’s HTML (or in the case of Report generation, PDF) content is generated.
On Print Style This event is fired on the server to allow for CSS style changes when the HTML representation of a control is being constructed.

   

Remarks

Data Binding

Use Data Field property to bound ComboBox control to the data source allowing to display information associated with a field in the Data Source. CombotBox bound to the Data Source in a single form mode will display all records available in the current page of the Dataset.

ComboBox can be configured to display list of items from lookup data source. You either need to set Data Field property to Relationship field, or set Lookup Data Source, Lookup Data Field and Lookup Text Field individually.

Use ComboBox "Refresh" method to re-read items from lookup data source if it represents a parametric query. This method is particularly useful when items of a parametric databound ComboBox needs updating based on a criteria or data supplied by a user. For example if there are two ComboBoxes used for presenting "Countries" and "States" and the items in the States ComboBox needs updating based on the selected country. The use of Refresh method is shown in the following example:

FX Code

Procedure frmRegister.comboCountryChange(Event: TDOMEvent);
Begin
    comboStates.Refresh('"prmCountry=' + comboCountry.Items[comboCountry.ItemIndex] + '"');
End;


The items (States) in the ComboStates Combobox are updated (using Refresh method) on the OnChange event of the comboCountry ComboBox.


Run-time behavior

You can manipulate with ComboBox items programmaticaly both in Server side and Browser side.

Server-Side Syntax

FX Code

Procedure Form1.ComboBox1BeforePrint(Sender: TWebControl; Canvas: TWebCanvas; Var Print: Boolean);
Begin
    ComboBox1.Items.Add('Red');
    ComboBox1.Items.Add('Green');
    ComboBox1.Items.Add('Blue');
End;
Browser-Side Syntax

FX Code

  ComboBox1.Add('Red');
  ComboBox1.Add('Green');
  ComboBox1.Add('Blue');

Related Topics