Select combo box default on focus

J

Jim Orson

Greetings!

I have a combo box set to display a default value (which is what I want).
However, when I tab to the combo box, the cursor is at the end of the text.
I would like to have the entire text highlighted when I tab to the combo box
so I can change the text easily with the keyboard if necessary. How can I
automatically select the entire text in the combo box when it receives the
focus? BTW, the default value is only a few characters wide.

Thanks

Jim...
 
W

Wayne Morgan

You have two options here. The first one will affect all controls.

1) Go to Tools|Options|Keyboard tab and choose the appropriate selection
under Behavior Entering Field.

2) In the GotFocus or Enter event use something like this:

Me.cboMyCombo.SelStart = 0
Me.cboMyCombo.SelLength = Len(Me.cboMyCombo.Text)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top