RichTextBox horizontal scrollbar

V

vooose

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

John Richardson

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

vooose

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
 
V

vooose

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top