tags:

views:

96

answers:

2

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).

A: 

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

John Knoeller
+4  A: 

GetPostitionFromCharIndex might be what you are looking for.

Cory Charlton
I cannot believe that I missed that one. :)
Josip Medved
Ya honestly until I started working on my RichTextBoxEx control (http://cccontrols.codeplex.com) I had never noticed the Get... methods on TextBoxBase either. Glad I could help.
Cory Charlton