0

I tried to add autoCompleteSource in vb.net textbox so it displays a list of suggestion. But I get this error. enter image description here

Is it because I try to add more than 300 records in suggestion . If so what can I do to add a scroll bar to display the records in suggestion. I guess I'll be needing to create my own handler if so could you suggest me the properties to consider to add scroll bar to create my own textbox autocomplete.

[UPDATE]

 Dim MySource As New AutoCompleteStringCollection()

        lst.Add("apple")
        lst.Add("applle")
        lst.Add("appple")
        lst.Add("appplee")
        lst.Add("bear")
        lst.Add("pear")

        'Records binded to the AutocompleteStringCollection.
        MySource.AddRange(lst.ToArray)

        'My own data source with 300 records

        Dim index(cmboList.Items.Count) As String
        For i As Integer = 0 To cmboList.Items.Count - 1
            If cmboList.Items.Count > 0 Then
                index(i) = cmboList.Items(i).ToString()
            End If
        Next
        MySource.AddRange(index.ToArray)

        txtExpressionBuilder.AutoCompleteCustomSource = MySource


        'Auto complete mode set to suggest append so that it will sugesst one
        'or more suggested completion strings it has bith ‘Suggest’ and
        '‘Append’ functionality
        txtExpressionBuilder.AutoCompleteMode = AutoCompleteMode.Suggest  ' SuggestAppend

        'Set to Custom source we have filled already
        txtExpressionBuilder.AutoCompleteSource = AutoCompleteSource.CustomSource
gowww
  • 139
  • 1
  • 12
  • 1
    I made a code update – gowww Sep 29 '16 at 20:49
  • Enable the native code debugging can solve the issue...try it.. – Raktim Biswas Sep 29 '16 at 20:53
  • I don't see any error in my code it starts only when i start typing so may be in txtchnaged method but i have nocode in it – gowww Sep 29 '16 at 20:57
  • it is not about the error, my friend...since you have so many records....and they are getting populated at once which is why it is locking the UI thread....so you need to run your program **asynchronously**.....but first, try [_enable unmanaged code debugging_](https://msdn.microsoft.com/en-us/library/tdw0c6sf(v=vs.100).aspx) under the project properties. – Raktim Biswas Sep 29 '16 at 21:12
  • 1
    Okay it helps... I guess it should be asynchronous. – gowww Sep 30 '16 at 14:24
  • see an example of [asynchronous programming](http://stackoverflow.com/a/39229074/6290553)....you'll get one basic idea from that :) – Raktim Biswas Sep 30 '16 at 15:08

0 Answers0