Type | Description |
The NotInList event notifies your application that the user enters a value in the text box portion of the combo box ( label ) that isn't in the combo box list. The NotInList property is fired when user presses the enter key or the control loses the focus. The NotInList event is fired only if the FireNotInList property is True. The NotInList event is not fired is the Style property is DropDownList. The NotInList event may not be fired if the AutoComplete property is True. This way the control's label portion always display the selection in the control's list as user types characters in the control's label area, so the text box portion of the control can't have a value that it is not in the combo box list. Use the EditText property to get the text from the control's label. Use the SelectItem property to select an item. Use the AddItem or InsertItem method to insert a new item to the control's drop down list.
Before running any of the following samples please make sure that the Style property is DropDown, FireNotInList property is True, AutoComplete property is False.
The following VB sample adds a new item, if it is not in the combo box list, when the user presses the ENTER key or the control loses the focus, using the NotInList event:
Private Sub ComboBox1_NotInList() With ComboBox1 Dim h As EXCOMBOBOXLibCtl.HITEM h = .Items.AddItem(.EditText(0)) .Items.SelectItem(h) = True End With End Sub Private Sub Form_Load() With ComboBox1 .BeginUpdate .AutoComplete = False .FireNotInList = True .ColumnAutoResize = True .HeaderVisible = False .Columns.Add "Column" With .Items .AddItem "Ana" .AddItem "Maria" End With .EndUpdate End With End Sub
The following JScript sample adds a new item if the control's drop down list doesn't contain it :
<SCRIPT FOR="ComboBox1" EVENT="NotInList()" LANGUAGE="javascript"> obj = document.getElementById ( "ComboBox1" ); h = obj.Items.AddItem(obj.EditText(0)); obj.Items.SelectItem(h) = true </SCRIPT>
The following C++ sample adds a new entry to the drop down list, when the user presses the ENTER key or the control loses the focus, using the NotInList event:
void OnNotInListCombobox1() { CItems items = m_combobox.GetItems(); long hItem = items.AddItem( COleVariant( m_combobox.GetEditText(COleVariant(long(0))) ) ); items.SetSelectItem( hItem, TRUE ); }
The following VB.NET sample adds a new entry to the drop down list, when the user presses the ENTER key or the control loses the focus, using the NotInList event:
Private Sub AxComboBox1_NotInList(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxComboBox1.NotInList With AxComboBox1 Dim h As Integer = .Items.AddItem(.get_EditText(0)) .Items.SelectItem(h) = True End With End Sub
The following C# sample adds a new entry to the drop down list, when the user presses the ENTER key or the control loses the focus, using the NotInList event:
private void axComboBox1_NotInList(object sender, EventArgs e) { EXCOMBOBOXLib.Items items = axComboBox1.Items; int hItem = items.AddItem(axComboBox1.get_EditText(0)); items.set_SelectItem(hItem, true); }
The following VFP sample adds a new entry to the drop down list, when the user presses the ENTER key or the control loses the focus, using the NotInList event:
*** ActiveX Control Event *** With thisform.ComboBox1 .Items.DefaultItem = .Items.AddItem(.EditText(0)) .Items.SelectItem(0) = .t. EndWithSyntax for NotInList event, /NET version, on:
private void NotInList(object sender) { } Private Sub NotInList(ByVal sender As System.Object) Handles NotInList End Sub |
private void NotInList(object sender, EventArgs e) { } void OnNotInList() { } void __fastcall NotInList(TObject *Sender) { } procedure NotInList(ASender: TObject; ); begin end; procedure NotInList(sender: System.Object; e: System.EventArgs); begin end; begin event NotInList() end event NotInList Private Sub NotInList(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotInList End Sub Private Sub NotInList() End Sub Private Sub NotInList() End Sub LPARAMETERS nop PROCEDURE OnNotInList(oComboBox) RETURN |
<SCRIPT EVENT="NotInList()" LANGUAGE="JScript"> </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Function NotInList() End Function </SCRIPT> Procedure OnComNotInList Forward Send OnComNotInList End_Procedure METHOD OCX_NotInList() CLASS MainDialog RETURN NIL void onEvent_NotInList() { } function NotInList as v () end function function nativeObject_NotInList() return |