RichTextBox line count?

M

M O J O

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
 
P

Peter Huang

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

M O J O

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
 
P

Peter Huang

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/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformstextboxbaseclasswordwraptopic.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/default.asp?url=/library/en-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.
 

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