Select all text in a combobox when a user clicks it

MartyL354

MartyL
Local time
, 19:26
Joined
Jan 12, 2009
Messages
14
Select all text in a combobox when it is clicked (not as obvious as it may look)

In the Got Focus event I use:
If cmbClient.Value & "" <> "" Then
cmbClient.SelStart = 0
cmbClient.SelLength = Len(cmbClient.Value)
End If

That works fine if the user tabs to the combobox but not if they click it.

I tried putting the same code in the Click event of the combobox but it doesn't work.

Thanks,

Marty
 
Last edited:
Gemma: marty has said he's already using gotfocus :-P

the following works for me

Code:
Private Sub txtControl_MouseUp(Button As Integer)
   Me.txtControl.SelStart = 0
   Me.txtControl.SelLength = Len(Me.StockEnv.Text)
End Sub
so i'm guessing the following should work for you

Code:
Private Sub cmbClient_MouseUp(Button As Integer)
If cmbClient.Value & "" <> "" Then
Me.cmbClient.SelStart = 0
Me.cmbClient.SelLength = Len(Me.cmbClient.Value)
End If
 
Last edited:

Users who are viewing this thread

Back
Top Bottom