Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GotFocus with mouse

Status
Not open for further replies.

ejgb

Programmer
Oct 24, 2001
41
GB
I have an issue when selecting a control with the mouse.

I am using the SelStart and SelLength properties in the GotFocus event on my controls, but when I get focus on the control using the mouse the text selected starts at the begining and only selected the text upto the point at where the mouse pointer is situated.

e.g.

If the contents of a textbox is "Please Select ...", and the mouse is used to get focus with the pointer over the S, the selected text is "Please S
 
If you want all of the text selected by the _GotFocus event, you can include the following code (assuming the name of the TextBox is Text1):

Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)

That will automatically select the entire text (which often is, but may not always be what is desired).

BlackburnKL
 
Maybe the mouse "click" is faster than got_Focus.
Try including mouse_up to call that got_focus.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top