property ComboBox.FireNotInList as Boolean
Specifies whether the control fires the NotInList event.

 TypeDescription 
   Boolean A boolean expression that specifies whether the control fires NotInList event.   

By default, the FireNotInList event is False. 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 event may not be fired if the AutoComplete property is True.

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.
EndWith

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.