I'm using the UltraCombo control in a winform application. Since there are a ton-of items in the database I'm using a background worker to to populate the datatable behind the UltraCombo. I don't know how to signal to the UltraCombo control to autocomplete what the user has typed in. For example, if the user typed in Fran and the datatable (which started being populated on the 3rd character) is has the items:
France, Frances, Franks, Frappacino
The dropdown section is populated, however the textbox section does not suggest Franks. Sure if I type in the letter k it autocompletes, but is there some kind of event I can raise on the UltraCombo to start the suggestion process as if the letter k was just typed in?
Thanks,
Frank
MSDN documentation on the SendKeys class is here.
Hi Bryan,
I was able to get something working, though probably not the "best" solution:
--------------------------------
Private Sub BuyerBGW_RunWorkerCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BuyerBGW.RunWorkerCompleted Dim dt As DataTable = CType(e.Result, DataTable) If Not IsNothing(dt) Then ddBuyer.BeginUpdate() ddBuyer.DataSource = dt ddBuyer.ValueMember = "Company_id" ddBuyer.DisplayMember = "Company_tx" ddBuyer.DisplayLayout.Bands(0).Columns("Company_id").Hidden = True ddBuyer.DisplayLayout.Bands(0).Columns("Company_tx").Header.Caption = "Buyer" ddBuyer.EndUpdate() End If
'Find item in dropdownbox If (ddBuyer.Text.Length >= 1 And ddBuyer.Rows.Count >= 1) Then Dim found As Integer = -1 Dim start As Integer = 0 Dim find As String = ddBuyer.Text.ToUpper() Dim word As String = "" For start = 0 To ddBuyer.Rows.Count - 1 word = ddBuyer.Rows(start).Cells("Company_tx").Value.ToString.ToUpper If (word.StartsWith(find)) Then found = start Exit For End If Next If found > -1 Then Dim currtext As String = ddBuyer.Text.ToString ddBuyer.SelectedRow = ddBuyer.Rows(found)
' fake the half text selection
ddBuyer.Textbox.SelectionStart() = currtext.Length End If End If End Sub
-------------------
I'm not quite sure how to use the SendKeys method to a specific text box, though that sounds like a much easier solution.
Sorry, I'm not sure if I am following this. Assuming you are using the 'SuggestAppend' setting, the first item that matches the text typed in the edit portion appears in the edit portion, so in this scenario 'France' should appear. I'm sure that some kind of timing issue is at play here but I am not understanding why you would expect 'Franks' to appear in the edit portion. Regarding "...some kind of event I can raise on the UltraCombo..."; no, there isn't, but the trigger for the refreshing of the list and the edit portion is the KeyPress event of the TextBox that is used for editing, so if you use SendKeys to send that key, that should simulate the act of the user typing that key, thus applying the new filter.