tags:

views:

30

answers:

3

Hey all, i am looking for a way to send a keypress letter/number to a textbox. The reason why i need this is that this textbox is a AutoComplete box that, when the user types, it displays a list of suggestions like google does.

However, for it to work, the user has to click in the box and type something. I can send any number/letter to the box i want using this code:

 Private Sub Command_Click()
     AutoComplete1.Text = "g"
 End Sub

And it does put it into the textbox but it does not trigger the autocomplete list (the list has words like "good","great","pop","test"). Only when i click in the textbox and type "g" is the only time i get the "good","great" suggestions.

Is there a way to trigger this with the code i posted above?

Thanks!

David

A: 

How about putting the code in the Key_Press event of the textbox instead of click event of the command button?

Raj More
It has a keypress within the code for the AutoComplete1 button (its a User Control) but it also has mousedown, mouseup, mousemove, keyup, keydown, keypress and change.
StealthRT
+1  A: 

Wouldn't

AutoComplete1.SetFocus()
SendKeys("g")

do that?

SteveCav
Does nothing still when adding the AutoComplete1.SetFocus.
StealthRT
@StealthRT Just to be sure, you did try `AutoComplete1.SetFocus(): SendKeys("g")` not `AutoComplete1.SetFocus(): AutoComplete1.Text = "g"`
MarkJ
A: 

My guess would be to use Keyup event and fire the code that displays the list of suggestion if it isn't fired by the Keyup event itself

Claudio