How to Selecte all text in textBox when double-click

M

mawenb

I have a textBox in my form, I want to select all the text when
double-click in textBox.The default behaviour is when double click on
the left of the text ,it will selcte the left -most word for examp if
the text is "-56", it will select and hightlight "-", if double click
on the right of the text , it will just select and hightlight "56". Is
there a way to selct and hightlight all the text "-56", when
double-click left/right of the text?
 
J

John Vinson

I have a textBox in my form, I want to select all the text when
double-click in textBox.The default behaviour is when double click on
the left of the text ,it will selcte the left -most word for examp if
the text is "-56", it will select and hightlight "-", if double click
on the right of the text , it will just select and hightlight "56". Is
there a way to selct and hightlight all the text "-56", when
double-click left/right of the text?

You can use some VBA code in the textbox's DoubleClick event:

Private Sub textboxname_DoubleClick()
Me.textboxname.SelStart = 0
Me.textboxname.SelLength = Len(Me.textboxname)
End Sub


It might be 1 instead of 0 for the SelStart... don't have Access open
to check.

John W. Vinson[MVP]
 

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