473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

RichTextBox line count?

Hi,

I'm using a RichTextBox with WordWrap=True and MultiLine=False.

When the text is to long, it fills more lines.

How do I get the number of lines the text uses?

Thanks!

M O J O

Nov 20 '05 #1
4 8432
Hi Mojo,

Thanks for posting in the community. My name is Peter, and I will be
assisting you on this issue.
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that when you use a RichTextBox with
WordWrap=True and MultiLine=False, if the text is to long, it fills more
lines. Also you wants to know how to get the number of lines the text uses.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my test, I can not reproduce the behavior I have enter 1780490
characters into the richtextbox, but there is only one line in the
richtextbox.( WordWrap=True and MultiLine=False)

So can you tell me what do you mean by the "long" in your post?

Also according to the MSDN doc, if you wants to display multiline in the
richtextbox, you may need to set the MultiLine=True, Why you wants to set
the multiline=False and display it as multiline and get its line count? Do
you have any specific need to do so, if so please post here, maybe there is
another solution.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
Hi Peter,

I'm trying to mimic the behavior of the To, Cc and Bcc textboxes in
Microsoft Outlook 2002/2003.

These textboxes look like they are RichTextBoxes.

If I enter many emailadresses, outlook will wordwrap these emailadresses
(it does not look like it is multiline). When Outlook wordwraps the
addresses, it also expands the height of the textboxes.

Therefor I would like to know how many lines my RichTextBox.Text uses,
so I can expand the height of the textboxes.

Hope you understand what I mean.

Thanks!

M O J O

Peter Huang wrote:
Hi Mojo,

Thanks for posting in the community. My name is Peter, and I will be
assisting you on this issue.
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that when you use a RichTextBox with
WordWrap=True and MultiLine=False, if the text is to long, it fills more
lines. Also you wants to know how to get the number of lines the text uses.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my test, I can not reproduce the behavior I have enter 1780490
characters into the richtextbox, but there is only one line in the
richtextbox.( WordWrap=True and MultiLine=False)

So can you tell me what do you mean by the "long" in your post?

Also according to the MSDN doc, if you wants to display multiline in the
richtextbox, you may need to set the MultiLine=True, Why you wants to set
the multiline=False and display it as multiline and get its line count? Do
you have any specific need to do so, if so please post here, maybe there is
another solution.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 20 '05 #3
Hi Mojo,

Thanks for your quickly reply!

I think the To, Cc and Bcc textboxes in Microsoft Outlook 2002/2003 should
be a multiline enabled RichTextBox, because we can insert the "Return" key
in the textboxs.

As the MSDN said,

TextBoxBase.WordWrap Property

Indicates whether a multiline text box control automatically wraps words to
the beginning of the next line when necessary.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformstextboxbaseclasswordwraptop ic.asp

WordWrap (inherited from TextBoxBase) Indicates whether a multiline text
box control automatically wraps words to the beginning of the next line
when necessary.

RichTextBox Members
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsrichtextboxmemberstopic.asp

That is to say, when you set WordWrap=True , you may need to let the
RichTextBox to be multiline, i.e. set the MultiLine= True.

Can you tell me why you need to set MultiLine=False?
What do you want to do, there may be another solution?
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
* M O J O <mojo@_no_spam_delete_this_newwebsolutions.dk> scripsit:
I'm using a RichTextBox with WordWrap=True and MultiLine=False.

When the text is to long, it fills more lines.

How do I get the number of lines the text uses?


Maybe you can convert this sample (which works with a standard textbox)
and use it with the richtextbox:

<http://www.activevb.de/tipps/vb6tipps/tipp0098.html>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Broderick | last post by:
I've got a problem with the RichTextBox control in .Net where the garbage collector doesn't reclaim its memory after I've finished with it. My program adds a series of rtb's to the control array...
2
by: Martin Dew | last post by:
I have a RichTextBox called rtbOutput. I am adding lines of text using the AppendText method. What I want to do is immediately after adding this line of text make sure that this line of text is...
6
by: Rachel Suddeth | last post by:
I have the index of a line in the Lines array of a RichTextBox. I would like to have it scroll so that line displays at the top. Is there no way to do this? The only way I can see to make it...
10
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
3
by: GSX | last post by:
I've been reading and searching (and searching and reading) for far too many hours. I'm rather new - so I apologize if this is an over asked question... I'm working on a small text editor as a...
0
by: John Bowman | last post by:
Hi All, I've got a RichTextBox control that has some variable length & language text in it that was retrieved from a resource file. When the text gets long enough the control automatically...
3
by: Venkatachalam | last post by:
Hello, I am reading a Column form the DataTable and have to display in the RichTextBox/TextBox (With Multi-line). When I try to do so: The width occupied by each charaters are not same and that...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
2
by: macky caliston | last post by:
Hi, Im having problems with the value being returned by the richtextbox.GetLineFromCharIndex method. Its returning a value that is more than the richtextbox.Lines.Length. Im trying to print...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.