471,570 Members | 1,305 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

RichTextBox horizontal scrollbar

Consider a RichTextBox which is say 200 pixels wide and you do:

richTextBox.WordWrap = false;
richTextBox.Rtf = <lots of text>

Assume the width of the rendered text is wider than 200 pixels so
horizontal scroll bars appear. How do you determine the actual size of
the text area? (so that you can determine the size richTextBox must be
to NOT show the scroll bars)

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 20 '05 #1
3 2985
take a look at
Graphics.MeasureString()

There is a rich API for drawing, and it takes a lot of reading to know all
the features, but reading up on this method will get you started.
You will need to know the font the string will be painted in.

Also, there is a .Net drawing or graphics newsgroup for these kinds of
questions that you can use as a resource as well.
"vooose" <no****@microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Consider a RichTextBox which is say 200 pixels wide and you do:

richTextBox.WordWrap = false;
richTextBox.Rtf = <lots of text>

Assume the width of the rendered text is wider than 200 pixels so
horizontal scroll bars appear. How do you determine the actual size of
the text area? (so that you can determine the size richTextBox must be
to NOT show the scroll bars)

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***

Dec 20 '05 #2
Thanks for your reply John. I am already familiar with
Graphics.MeasureString(). This will give me a good result but not
perfect...besides, the RichTextBox "knows" somewhere how wide it is
before it has to display the scroll bars so why should I have to
calculate it again? (and perhaps not perfectly nor taking into account
borders and any other fudge factors)

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 20 '05 #3
>Also, there is a .Net drawing or graphics newsgroup for these >kinds of
questions that you can use as a resource as well.

Where do you suggest besides the MSDN forums?

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by anna | last post: by
1 post views Thread by Thomas Kehl | last post: by
1 post views Thread by Rachel Suddeth | last post: by
reply views Thread by Rachel Suddeth | last post: by
4 posts views Thread by Sakharam Phapale | last post: by
14 posts views Thread by Michael Weis | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | 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.