View Full Version : Getting location from DotNet textBox

04 April 2008, 01:56 AM
Just wondering how I can get the position index where the user is current typing with a dotNet textBox? I'm guessing I have to use GetCharIndexFromPosition pt ? I'm pretty new with dotnet, so I'm still trying to get a hang of it.

04 April 2008, 11:58 AM

Note that this does not necessarily contain the exact caret position (be darned if I can find that).
If no text is selected, then this contains the caret position.

If text -is- selected, then this contains the starting position of that selection. However, whether the caret is at that same position depends on whether they selected from the right to the left (then it is), or from the left to the right (then it isn't).
This is a bit semantical, however, as pressing any new letter to drop in text will replace the entire selected text starting at selectionStart anyway.

04 April 2008, 05:15 PM
That's exactly what I needed! Thanks Richard!

CGTalk Moderation
04 April 2008, 05:15 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.