Getting XY of text location in TextBox / RichTextBox

How to get the coordinates of a specific character in a TextBox and / or RichTextBox?

I will try to explain this through a function:

Point GetXY(int characterIndex) { //do some magic return new Point(x, y); } 

The idea is to find where the selected text is, so that the search dialog will not be displayed above that location, but will be moved to the side (as Word does).

+4
source share
2 answers

GetPostitionFromCharIndex may be what you are looking for.

+4
source

You can do this using the interop to SendMessage message EM_POSFROMCHAR .

+1
source

Source: https://habr.com/ru/post/1301502/


All Articles