3

I want to create a ComboBox that automaitcally drops down the words containing the letter based on the input. My dropdownstyle is dropdown so the combobox has an input field.

For example i would input the letter A or a I want the ComboBox to automatically dropdown the words which contains the letter A or a. The contents of the ComboBox are being set by myself manually.

Is this possible? Thanks in advance.

4

2 に答える 2

3

これらを設定する必要があります

AutoCompleteMode: SuggestAppend
AutoCompleteSource: ListItems
DropDownStyle: DropDown

コンボにこれらのアイテムがあると仮定すると、それらを autocompletecustomsource にも追加する必要があります

ComboBox1.Items.Add("10")
ComboBox1.Items.Add("92")
ComboBox1.Items.Add("9000")
ComboBox1.Items.Add("9001")

ComboBox1.AutoCompleteCustomSource.Add("10")
ComboBox1.AutoCompleteCustomSource.Add("92")
ComboBox1.AutoCompleteCustomSource.Add("9000")
ComboBox1.AutoCompleteCustomSource.Add("9001")

ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
于 2013-09-07T06:05:22.843 に答える
1

はい、これは次のようにAutoCompleteModeandを介して可能AutoCompleteです:

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
               ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource

        'Add some options
        ComboBox1.AutoCompleteCustomSource.Add("ABC")
        ComboBox1.AutoCompleteCustomSource.Add("BCD")
        ComboBox1.AutoCompleteCustomSource.Add("CDE")
    End Sub

    'Add ComboBox1.Text to AutoCompleteCustomSource collection when leaving ComboBox
    Private Sub ComboBox1_Leave(ByVal sender As System.Object, _
               ByVal e As System.EventArgs) Handles ComboBox1.Leave
        ComboBox1.AutoCompleteCustomSource.Add(ComboBox1.Text)
    End Sub
End Class

詳細については、 AutoCompleteMode 列挙を参照してください。

詳細については、 AutoCompleteSource 列挙を参照してください。

于 2013-09-07T06:05:30.627 に答える