Auto complete textbox suggestions in vb.net

2019-08-12 17:08发布

I implemented auto complete in vb.net textbox , but there is an issue that when user types something in text box the auto complete suggestion list blinks and disappears like if the focus changed

here is the code:

        Dim Bl As New ItemBL
        Dim suggestions = DAL.DisplayLikeNameList(Trim(MyTextBox.Text))
        Dim MySource As New AutoCompleteStringCollection()
        MySource.AddRange(suggestions.ToArray)

        With MyTextBox
            .AutoCompleteCustomSource = MySource
            .AutoCompleteMode = AutoCompleteMode.Suggest
            .AutoCompleteSource = AutoCompleteSource.CustomSource
        End With
    End If

I believe the problem in Mdi form because it has timer code executed after the above code :

 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    LblDateAndTime.Text = Now
End Sub

Note: the auto complete code is executed in a child form not in the Mdi Form , what do you suggest to keep suggestions list "sticky" as the user writing in the text box ??

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-12 17:38

I solved the issue ,

This Code was written in Key_Up event but now I wrote it in Text_Changed Event and it worked

查看更多
登录 后发表回答