PDA

View Full Version : Getting location from DotNet textBox


labbejason
04-14-2008, 02: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.

ZeBoxx2
04-14-2008, 12:58 PM
<textbox>.selectionStart

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.

labbejason
04-14-2008, 06:15 PM
That's exactly what I needed! Thanks Richard!

CGTalk Moderation
04-14-2008, 06: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.