How to get text width and hieght in a richtext box

  • Thread starter Thread starter Pubs
  • Start date Start date
P

Pubs

Hi all,

I have application being written in C# where I have to calculate the
text pixel height and width of the line being typed in rich text box.
I need to get the pixel height of the character next to cursor and the
total length of the row where the cursor is. Rich text box might have
different fonts with different styles I need to get the length in
pixels.
Can some one let me know an easy method ?

Pubdu
 
Hi all,

  I have application being written in C# where I have to calculate the
text pixel height and width of the line being typed in rich text box.
I need to get the pixel height of the character next to cursor and the
total length of the row where the cursor is. Rich text box might have
different fonts with different styles I need to get the length in
pixels.
Can some one let me know an easy method ?

Pubdu

Hi,
I do not know how to get it from inside the RichTextBox, but you can
use Graphics.MeasureString , all you need to know is the string and
the Font to use
 
Hi,
I do not know how to get it from inside the RichTextBox, but you can
use Graphics.MeasureString , all you need to know is the string and
the Font to use

thank you for the replyt
 
Is there a way to scroll the text of the richtext Box to a specific Line
number and makes the cursor points to that Line Number?

You should look at the following members of TextBoxBase (from which
RichTextBox derives):

GetFirstCharIndexFromLine
Select
ScrollToCaret

To position the caret in the textbox, you need to "select" zero characters
starting at the position you want to put the caret at.
 
Back
Top