Josip Medved
Josip Medved

Reputation: 3711

Getting XY location of text within TextBox/RichTextBox

How to get coordinates of certain character within TextBox and/or RichTextBox?

I will try to explain this through function:

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

Idea is to find where selected text is located so Find dialog will not be displayed over this location but moved to side (like Word is doing).

Upvotes: 5

Views: 3775

Answers (2)

Cory Charlton
Cory Charlton

Reputation: 8938

GetPostitionFromCharIndex might be what you are looking for.

Upvotes: 5

John Knoeller
John Knoeller

Reputation: 34138

You can do this by using interop to SendMessage an EM_POSFROMCHAR message.

Upvotes: 1

Related Questions