Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting XY location of text within TextBox/RichTextBox

Tags:

c#

.net

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

like image 418
Josip Medved Avatar asked Feb 16 '10 21:02

Josip Medved


People also ask

What is Richtext box?

The RichTextBox control enables you to display or edit flow content including paragraphs, images, tables, and more. This topic introduces the TextBox class and provides examples of how to use it in both Extensible Application Markup Language (XAML) and C#.

How do you know if a rich text box is empty?

Answers. Hi, you can check RichTextBox. TextLength, if it is 0, means RichTextBox is empty of text and images.


1 Answers

GetPostitionFromCharIndex might be what you are looking for.

like image 141
Cory Charlton Avatar answered Oct 17 '22 17:10

Cory Charlton