Insertion Point in TextBox

jaydwest

JayW
Local time
Today, 09:47
Joined
Apr 22, 2003
Messages
340
I would like to click in a text box and know the insertion point so I can insert a string at the insertion point.

Any suggestions?

Thanks for you help
 
You can control the insertion point location using the SelStart method of textboxes. Use some code like this:
Me.txtTest.SelStart = 2
Just make sure the textbox has the focus before you attempt to use the method else you'll get an error.
 
Thanks for your response. Well it kinda works. I have been able to display the insertion point correctly, but is is very very intermitent. For some reason it doesn't seem to want to set the focus in the text box even though I'm clicking in it.

I have tried setting the focus in the text box (in code) but this has no affect. It mostly returns 0

Until I can get this to work right, I can get it to work first by clicking an insertion point in the textbox and then pressing the {ctrl} key down and clicking in the textbox again. (I use the MouseDn Event.
 
If you click in the text box it already has the focus, using code to set focus to it whilst in it is pointless.
 
My problem seems to be that the selstart doesn't want to work on the mousedn event. It works consistently on the click event. Now I have to figure out how to use this for selected purposes.
 

Users who are viewing this thread

Back
Top Bottom