473,473 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3069
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jsp | last post by:
I created a vertically scrolling div. On initial rendering, Firefox shows a horizontal scrollbar in this div, over the complete width. Resizing the width of the window/viewport makes the horizontal...
4
by: anna | last post by:
How to tell if a horizontal scrollbar is present? I only want to use scrollTo if horizontal scrollbar is present. window.scrollbars.visibility doesn't specify which scrollbar is present, so it...
1
by: Thomas Kehl | last post by:
Hi! I have a RichTextBox. I set the Property RightMargin of this Box to a value, that i will not show the horizontal scrollbar. Now, the RichTextBox Wrap the Lines automatically. Now I would...
1
by: Rachel Suddeth | last post by:
I would like to load a file to the .Rtf property of a RichTextBox, and then set the containing form (if possible, depending on screen resolution) to the smallest width that will not cause the...
0
by: Rachel Suddeth | last post by:
I am using GetScrollRange to set a "preferred width" for a UserControl that contains a RichTextBox. I think this should return the smallest width such that no horizontal scroll will be needed. Most...
4
by: Sakharam Phapale | last post by:
Hi All, I have installed VS .NET 2002 on my machine. I have checked both Vertical scrollbar and Horizontal Scrollbar options, in Tools -> Options-> Text Editor-> General-> Vertical Scrollbar...
14
by: Michael Weis | last post by:
Hello all, as a non-professional in these things, I searched for this topic but found no satisfying answer: I have to create a site with 3 frames. (Please no diskussion about the sense of...
1
by: malpani.abhijit | last post by:
Hi, I am having a ListView component in my WinForm, when i add some images into it, it gives me a vertical scroll bar. What i want is, the horizontal scrollbar instead of vertical. Is there any...
3
by: j0rd4n | last post by:
I have a user control that needs to allow vertical scrolling but not horizontal scrolling. In the user control's resize event, I need to adjust the size of all the children controls. For this to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.