PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Re: rtf problem - nonbreaking hyphen breaks + other problems (REVISED)

Reply

Re: rtf problem - nonbreaking hyphen breaks + other problems (REVISED)

 
Thread Tools Rate Thread
Old 01-06-2005, 07:30 PM   #1
=?Utf-8?B?dHNpR2Vvcmdl?=
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVISED)


I'm using a read only rich text box to format some text. In the text is a
series of phone numbers separated by a comma and a space. I don't want the
phone numbers to be split.

Here's what I've done. I replace '-' with '\_'which is supposed to be the
non-breaking hyphen. If I look at the string before it is stored in the
rtf it looks like ';555\_201\_1234, 555\_201\_1111, '. In the rtf it looks
like '555-201-1234, 555-201-1111, '.

When the form is displayed at the normal size, the series of phone numbers
are displayed correctly except that the space after the comma is at the
beginning of the next line.

When the form is made larger the vertical scroll bar is removed (the rtf
box fits on the screen) and the series of phone numbers split on one of the
hyphens screwing up the format. If there enough phone numbers to keep the
vertical scroll bar, the data is displayed correctly, except that the lines
start with a space.

When the form is restored to it's original size, the vertical scroll bar is
missing if it wasn't required on the larger window. If you set the cursor in
the rtf box and move the cursor down the vertical scroll bar appears.

I see 3 problems:

1. The rtf control string for a nonbreaking hyphen doesn't work.
2. If a line is split on a space the space should be at the end of the line.
3. Vertical scroll bar is missing when required.
--
tsiGeorge
  Reply With Quote
Old 02-06-2005, 07:58 AM   #2
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVISED)

Hi tsiGeorge,

Thanks for your post.

I do not think I understand your scenario well.

First, how do you store ";555\_201\_1234, 555\_201\_1111, " string in the
rtf? This statement:
this.richTextBox1.Rtf=@";555\_201\_1234, 555\_201\_1111, ";
will generate an " Invalid file format." exception

Second, defaultly, I do not know how your vertical scrollbar appears? I
think there is only single text in the richtextbox, which should not cause
the vertical scrollbar to appear.

Currently, I suggest you attach a sample project for us to demonstrate this
issue. Then we can understand your problem better. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Old 02-06-2005, 02:35 PM   #3
=?Utf-8?B?dHNpR2Vvcmdl?=
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

Jeffrey
(you may remember me from the MDI client problem)
Try this for the string
Dim I as integer
Dim S as string
For I = 0 to 25
S &= "555\_201\_1234, 555\_201\_1111, "
Next
S = S.Substring(0, S.Length-2)
RichTextBox1.rtf = "{\rtf1\ansi " & S & "}"

Create a MDI client form.
Set the rich text box width so that 3 phone numbers are displayed per line
and the height so the vertical scroll bar is active. Maximize the form and
then restore to the orignal size.
--
tsiGeorge


""Jeffrey Tan[MSFT]"" wrote:

> Hi tsiGeorge,
>
> Thanks for your post.
>
> I do not think I understand your scenario well.
>
> First, how do you store ";555\_201\_1234, 555\_201\_1111, " string in the
> rtf? This statement:
> this.richTextBox1.Rtf=@";555\_201\_1234, 555\_201\_1111, ";
> will generate an " Invalid file format." exception
>
> Second, defaultly, I do not know how your vertical scrollbar appears? I
> think there is only single text in the richtextbox, which should not cause
> the vertical scrollbar to appear.
>
> Currently, I suggest you attach a sample project for us to demonstrate this
> issue. Then we can understand your problem better. Thanks
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>

  Reply With Quote
Old 06-06-2005, 09:04 AM   #4
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVISION)

Hi George,

Thanks for your reproduce project.

With it, I can reproduce your #3 vertical scrollbar disappear issue.
Currently, I am not sure what internally cause out this problem, however,
we can workaround this issue with adding a refresh statement call after the
height changing. Like this:

Private Sub Form2_resize(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.SizeChanged
RichTextBox1.Size = New Drawing.Size(RichTextBox1.Size.Width, _
lblMsg.Location.Y - RichTextBox1.Location.Y - 8)
Me.RichTextBox1.Refresh()
End Sub

After adding this line of code, it should work well.

For #1 and #2, I think I still did not understand your point. When I run
the project, I can see certain phone number splitted on my machine like
this:
218-229-2908, 218-283-0932, 218-365-0064, 218-365-0843, 218-834-0781,
218-834-0783, 320-558-4021, 320-
558-4023, 320-692-4398, 320-692-4715, 320-983-2870, 320-983-6245,
507-423-1045, 651-257-2635, 651-462-
0649, 763-479-2503, 763-972-5894, 952-446-8167, 952-446-8169, 952-472-3782,
952-472-5089

For #2, can you show me you steps about how to force the line to splitted
by a space?

I will wait for your further feedback. Thanks
=====================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Old 07-06-2005, 02:43 AM   #5
=?Utf-8?B?dHNpR2Vvcmdl?=
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

Jeffrey
The refresh workaround worked.

On the splitting problems.
When the windows is a maximum size look at
218-834-0783, 320-558-4021, 320-
> 558-4023, 320-692-4398, 320-692-4715, 320-983-2870, 320-983-6245,

Notice that the phone number 320-558-4023 was split on 2 lines. But the
hyphens are nonbreaking hyphens. In rtf code \_ was used.

When the window is at the minimum size notice that the phone numbers are
slightly to the right of all the other values in the right column. If you
look at the value of the S variable (i think it's S) you will see it starts
with a space so that when the string is split on a space the phone numbers
still line up. It is very obvious that when the string is split on a space
the space is at the beginning of the line when the initial space is removed.
Hope this makes sense to you. The phone numbers should always be displayed in
nice columns.
--
tsiGeorge


""Jeffrey Tan[MSFT]"" wrote:

> Hi George,
>
> Thanks for your reproduce project.
>
> With it, I can reproduce your #3 vertical scrollbar disappear issue.
> Currently, I am not sure what internally cause out this problem, however,
> we can workaround this issue with adding a refresh statement call after the
> height changing. Like this:
>
> Private Sub Form2_resize(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.SizeChanged
> RichTextBox1.Size = New Drawing.Size(RichTextBox1.Size.Width, _
> lblMsg.Location.Y - RichTextBox1.Location.Y - 8)
> Me.RichTextBox1.Refresh()
> End Sub
>
> After adding this line of code, it should work well.
>
> For #1 and #2, I think I still did not understand your point. When I run
> the project, I can see certain phone number splitted on my machine like
> this:
> 218-229-2908, 218-283-0932, 218-365-0064, 218-365-0843, 218-834-0781,
> 218-834-0783, 320-558-4021, 320-
> 558-4023, 320-692-4398, 320-692-4715, 320-983-2870, 320-983-6245,
> 507-423-1045, 651-257-2635, 651-462-
> 0649, 763-479-2503, 763-972-5894, 952-446-8167, 952-446-8169, 952-472-3782,
> 952-472-5089
>
> For #2, can you show me you steps about how to force the line to splitted
> by a space?
>
> I will wait for your further feedback. Thanks
> =====================================================
> Thank you for your patience and cooperation. If you have any questions or
> concerns, please feel free to post it in the group. I am standing by to be
> of assistance.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>

  Reply With Quote
Old 07-06-2005, 08:12 AM   #6
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

Hi tsiGeorge,

Thanks for your feedback.

With your further feedback, I think I understand your problem.

First, nonbreaking hyphen is "\_" in RTF specification, not "\emdash", so I
have replaced all the "\emdash" with "\_" in your project. However, it
seems that this also does not work.

Second, I have also seen your space at the begining of each line problem.

For these 2 issues, I will spend a little more time into them, I will
update you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Old 07-06-2005, 10:16 PM   #7
=?Utf-8?B?dHNpR2Vvcmdl?=
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

Jeffrey,
Sorry about that. I've tried \_, \endash, \emdash and none of them worked.
Your would think an \endash would work since it isn't a hyphen but once it
gets loaded into the rtf variable they all look alike.
--
tsiGeorge


""Jeffrey Tan[MSFT]"" wrote:

> Hi tsiGeorge,
>
> Thanks for your feedback.
>
> With your further feedback, I think I understand your problem.
>
> First, nonbreaking hyphen is "\_" in RTF specification, not "\emdash", so I
> have replaced all the "\emdash" with "\_" in your project. However, it
> seems that this also does not work.
>
> Second, I have also seen your space at the begining of each line problem.
>
> For these 2 issues, I will spend a little more time into them, I will
> update you ASAP. Thanks for your understanding.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>

  Reply With Quote
Old 10-06-2005, 10:17 AM   #8
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

Hi tsiGeorge,

Sorry for letting you wait for so long.

I have contacted our product team for this issue, and below is their
feedback:
"It looks like the Unicode character richedit supports as a nonbreaking
hyphen is 8209: try replacing
320\_558\_4021
with
320\u8209?558\u8209?4021"

So I suggest you try to replace "\_" with "\u8209?" to see if this helps.
Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Old 10-06-2005, 10:22 AM   #9
Sine Nomine
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

On 10/06/05 10:17, Jeffrey Tan[MSFT] wrote:
> I have contacted our product team for this issue, and below is their
> feedback:
> "It looks like the Unicode character richedit supports as a nonbreaking
> hyphen is 8209: try replacing
> 320\_558\_4021
> with
> 320\u8209?558\u8209?4021"
>
> So I suggest you try to replace "\_" with "\u8209?" to see if this helps.


Non-breaking space also doesn't work - any ideas for that one?

Thanks.
  Reply With Quote
Old 11-06-2005, 05:17 PM   #10
=?Utf-8?B?dHNpR2Vvcmdl?=
Guest
 
Posts: n/a
Default Re: rtf problem - nonbreaking hyphen breaks + other problems (REVI

Jeffrey

Doesn't work at all. Shows up as an illegal character (small box).
--
tsiGeorge


""Jeffrey Tan[MSFT]"" wrote:

> Hi tsiGeorge,
>
> Sorry for letting you wait for so long.
>
> I have contacted our product team for this issue, and below is their
> feedback:
> "It looks like the Unicode character richedit supports as a nonbreaking
> hyphen is 8209: try replacing
> 320\_558\_4021
> with
> 320\u8209?558\u8209?4021"
>
> So I suggest you try to replace "\_" with "\u8209?" to see if this helps.
> Thanks
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off