471,349 Members | 1,260 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

How to get text width and hieght in a richtext box

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
Jun 27 '08 #1
4 4522
On Jun 17, 12:25*pm, Pubs <pubud...@gmail.comwrote:
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
Jun 27 '08 #2
On Jun 17, 2:50*pm, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On Jun 17, 12:25*pm, Pubs <pubud...@gmail.comwrote:
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
thank you for the replyt
Jun 27 '08 #3
Hi,

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?

Thanks,
Dhivya

Sep 8 '08 #4
<Dhivya Rwrote in message news:20*************************@gmail.com...
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.
Sep 8 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Carlos Lozano | last post: by
reply views Thread by Stuart Woodard | last post: by
5 posts views Thread by Brian Lowe | last post: by
4 posts views Thread by iwdu15 | last post: by
9 posts views Thread by Rajesh | last post: by
12 posts views Thread by Keith G Hicks | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.