protected function Form_Create()
{
// Define the Controls
$this->lstListbox = new QListBox($this);
$this->lstListbox->Name = 'Items to Choose From';
$this->lstListbox->Rows = 6;
// When the the user changes the selection on the listbox, we'll call lstListbox_Change
$this->lstListbox->AddAction(new QChangeEvent(), new QAjaxAction('lstListbox_Change'));
$this->lstListbox->AddItem('Sample Item', 'Sample Item');
$this->txtItem = new QTextBox($this);
$this->txtItem->Name = 'Item to Add';
$this->btnAdd = new QButton($this);
$this->btnAdd->Text = 'Add Item';
$this->lblSelected = new QLabel($this);
$this->lblSelected->Name = 'Item Currently Selected';
$this->lblSelected->Text = '<none>';
// When we submit, we want to do the following actions:
// * Immediately disable the button, textbox and listbox
// * Perform the AddListItem action via AJAX
$objSubmitListItemActions = array(new QToggleEnableAction($this->btnAdd, false), new QToggleEnableAction($this->txtItem, false), new QToggleEnableAction($this->lstListbox, false), new QAjaxAction('AddListItem'));
// Let's add this set of actions to the Add Button
$this->btnAdd->AddActionArray(new QClickEvent(), $objSubmitListItemActions);
// Let's add this set of actions to the Textbox, as a EnterKeyEvent
$this->txtItem->AddActionArray(new QEnterKeyEvent(), $objSubmitListItemActions);
// Because the enter key will also call form.submit() on some browsers, which we
// absolutely DON'T want to have happen, let's be sure to terminate any additional
// actions on EnterKey
$this->txtItem->AddAction(new QEnterKeyEvent(), new QTerminateAction());
}