Textbox cursor Point.

O

objectref

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top