ComboBox

From HTML5 Builder
Jump to: navigation, search

ComboBox is a combo box, a field whose value user can choose from a list of possible values, defined by you.

Usage

Fill From a Datasource

You can fill a ComboBox from a DataSource component with a function like this one:

function loadComboBox($sender, $params)
{
	$this->DataSource1->DataSet->first();
	while( ! $this->DataSource1->DataSet->EOF )
	{
		$this->ComboBox1->AddItem($this->DataSource1->DataSet->Fields["column_name"]);
		$this->DataSource1->DataSet->next();
	}
}

You can call it from your form’s onBeforeShow event.

Get Selected Item

You can get the selected item from PHP with the following code:

$selectedItem = $this->ComboBox->Items[$this->ComboBox->ItemIndex];

You can also use JavaScript:

ComboBox = jQuery('#ComboBox');
selectedItem = ComboBox.options[ComboBox.selectedIndex].text;

Properties

Name Values Description
DataSource

Datasource Connector to a DataSet component with rows to fill the ComboBox.
Items

array Array of key-value pairs, where the value is the text displayed on the ComboBox, and the key is an unique identifier.
ParentColor

boolean Whether or not Color property value should be inherited from ComboBox’s parent component.
ParentFont

boolean Whether or not Font property value should be inherited from ComboBox’s parent component.
ParentShowHint

boolean Whether or not ShowHint property value should be inherited from ComboBox’s parent component.