By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Textbox cursor Point.

P: n/a
Hi to all,

we have the MousePosition property that we can get the Point of the position
of the mouse cursor on the screen, but is it there a way to get the
respective Point
of a cursor in a TextBox ?? (relative to screen)

I mean, i have a textbox that i write some text and i want to know the exact
point location
of the cursor at any time a character is displayed.

Is there a way to do this ??
Thanks a lot for any help
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Directly no... however with a little math and some crazy-go-nuts code... kinda.

Locating the cursor position within the text box (row and column) would be
possible by doing some work with the SelectionStart property and Lines...
however that would be insufficient as it would not tell you exactly where you
are in the TextBox due to the potential for scrolling.

With scrolling in the picture, the answer is ultimately no, as you have no
good way of knowing exactly within the textbox where you are and where that
relates to the rest of the control.

Without scrolling, you can do some math based on the row/column position
within the textbox and the font in use to calculate the position, this method
should still work even if you are not using a fixed width font given that the
rows are already specified. From that, it would be simple math to determine
the position further by throwing in the TextBox’s position on the form and
the forms position within Windows.

Brendan
"objectref" wrote:
Hi to all,

we have the MousePosition property that we can get the Point of the position
of the mouse cursor on the screen, but is it there a way to get the
respective Point
of a cursor in a TextBox ?? (relative to screen)

I mean, i have a textbox that i write some text and i want to know the exact
point location
of the cursor at any time a character is displayed.

Is there a way to do this ??
Thanks a lot for any help

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.