Vb.net + AutoComplete in textboxes

后端 未结 2 1884
时光取名叫无心
时光取名叫无心 2021-01-13 13:14

So I was reading a bit on AutoComplete of textboxes in VB.NET, but I can\'t really understand where these are stored? Is it a fully built in feature, or do I have to write s

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-13 13:51

    first create the list to use as the custom source.

    Dim MySource As New AutoCompleteStringCollection()
    

    and then set the property of the textbox

    With MyTextbox
       .AutoCompleteCustomSource = MySource
       .AutoCompleteMode = AutoCompleteMode.SuggestAppend
       .AutoCompleteSource = AutoCompleteSource.CustomSource
    End With
    

    put this code in eventlistener you use for validating the input field, e.g. btnOK.Click

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        MySource.Add(txtinput.text)
    End Sub
    

提交回复
热议问题