Connecting Tech Pros Worldwide Help | Site Map

Displaying Text in a RichtText Control Problems,...

=?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=
Guest
 
Posts: n/a
#1: Aug 28 '08
Hi,

i have text like this:

"ACPI\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\_0"

an after displaying it in a RichTextBox as RTF string, i get this:

"ACPI_-_x86_Family_6_Model_13 "

How can i enclose this text section, so that the RTF Engine
does it print exactly the way it is add and does not treat
backslashes and stuff like that as control charatcers,...

I know that it is a little OT, but i did not kow where to ask,...

TIA,...

Regards

Kerem


--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Caio Proiete [MCT]
Guest
 
Posts: n/a
#2: Aug 28 '08

re: Displaying Text in a RichtText Control Problems,...


Hello Kerem,

How are you inserting the string in the RichTextBox?

If you use the property "Text", it should work... Something like:

yourRichTextBox.Text = @"ACPI\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\_0";

or

yourRichTextBox.Text = "ACPI\\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\\_0";

Cheers,
Caio Proiete



Quote:
Hi,
>
i have text like this:
>
"ACPI\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\_0"
>
an after displaying it in a RichTextBox as RTF string, i get this:
>
"ACPI_-_x86_Family_6_Model_13 "
>
How can i enclose this text section, so that the RTF Engine does it
print exactly the way it is add and does not treat backslashes and
stuff like that as control charatcers,...
>
I know that it is a little OT, but i did not kow where to ask,...
>
TIA,...
>
Regards
>
Kerem
>

=?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=
Guest
 
Posts: n/a
#3: Aug 28 '08

re: Displaying Text in a RichtText Control Problems,...


Hi Caoi,

i insert is as a formated RichText, because i want a
basic format for it. The RTF String looks like:


@"{\rtf1 {\colortbl ;\red0\green128\blue0;\red0\green0\blue255;}{\b " +
ObjectProperty.Name + @"} \par \b0 {" + da.Description + @"}\par {\b
Value: }\cf1\b0 " + ObjectValue + @" \b0 \par}";

Its an excerpt from an self-made property grid, where this block is the part
or the description pane in the lower part of the property gridls panel. The
Problem for the Rtf-Property of the RichTextBox are the "\" Backslashes,
since everything after it will be considered as a cotrol command. But there
must be some way to enclose the String as a non Rtf string or like something
"treat the string as is" inside a RFT string,...

Is there a way

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Caio Proiete [MCT]" <caio-mspublicnews@proiete.comschrieb im Newsbeitrag
news:c69190b31a08cad770c95d0d0c@msnews.microsoft.c om...
Quote:
Hello Kerem,
>
How are you inserting the string in the RichTextBox?
>
If you use the property "Text", it should work... Something like:
>
yourRichTextBox.Text = @"ACPI\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\_0";
>
or
>
yourRichTextBox.Text = "ACPI\\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\\_0";
>
Cheers,
Caio Proiete
>
>
>
>
Quote:
>Hi,
>>
>i have text like this:
>>
>"ACPI\GENUINEINTEL_-_X86_FAMILY_6_MODEL_13\_0"
>>
>an after displaying it in a RichTextBox as RTF string, i get this:
>>
>"ACPI_-_x86_Family_6_Model_13 "
>>
>How can i enclose this text section, so that the RTF Engine does it
>print exactly the way it is add and does not treat backslashes and
>stuff like that as control charatcers,...
>>
>I know that it is a little OT, but i did not kow where to ask,...
>>
>TIA,...
>>
>Regards
>>
>Kerem
>>
>
>
Caio Proiete [MCT]
Guest
 
Posts: n/a
#4: Aug 29 '08

re: Displaying Text in a RichtText Control Problems,...


Hum.. Okay.

Just replace each backslash to *two* backslashes, as do in C# when you don't
use the "@" :).

Something like:

@"{\rtf1 {\colortbl ;\red0\green128\blue0;\red0\green0\blue255;}{\b "
+ ObjectProperty.Name.Replace(@"\", @"\\")
+ @"} \par \b0 {"
+ da.Description
+ @"}\par {\b Value: }\cf1\b0 "
+ ObjectValue.ToString().Replace(@"\", @"\\")
+ @" \b0 \par}";


This is probably not be the most efficient solution, though... You should
think of using a StringBuilder and use the Append method to build the correct
RTF string...

--
Caio Proiete
http://www.caioproiete.com


-
Quote:
Hi Caoi,
>
i insert is as a formated RichText, because i want a basic format for
it. The RTF String looks like:
>
@"{\rtf1 {\colortbl ;\red0\green128\blue0;\red0\green0\blue255;}{\b "
+ ObjectProperty.Name + @"} \par \b0 {" + da.Description + @"}\par {\b
Value: }\cf1\b0 " + ObjectValue + @" \b0 \par}";
>
Its an excerpt from an self-made property grid, where this block is
the part or the description pane in the lower part of the property
gridls panel. The Problem for the Rtf-Property of the RichTextBox are
the "\" Backslashes, since everything after it will be considered as a
cotrol command. But there must be some way to enclose the String as a
non Rtf string or like something "treat the string as is" inside a RFT
string,...
>
Is there a way
>
Regards
>
Kerem
>

=?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=
Guest
 
Posts: n/a
#5: Aug 29 '08

re: Displaying Text in a RichtText Control Problems,...


Hi Caio,
Quote:
>Just replace each backslash to *two* backslashes, as >do in C# when you
>don't use the "@" :).
well, this is no real solution, since the could be a
situation were you have to backslashes and then
you will have three there. There must be some way,
to represent a string as is inside a RTF string. I could
not find something i the RTF Documentation yet, but
there should be some way. The @ quoting is no
difference to me or the string.append or other string
methods. Here is no need for them,...

Maybe there is another solution,...

Regards

Kerem


--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Caio Proiete [MCT]" <caio-mspublicnews@proiete.comschrieb im Newsbeitrag
news:c69190b369e8cad780f64cdabc@msnews.microsoft.c om...
Quote:
Hum.. Okay.
>
Just replace each backslash to *two* backslashes, as do in C# when you
don't use the "@" :).
>
Something like:
>
@"{\rtf1 {\colortbl ;\red0\green128\blue0;\red0\green0\blue255;}{\b "
+ ObjectProperty.Name.Replace(@"\", @"\\") + @"} \par \b0 {" +
da.Description + @"}\par {\b Value: }\cf1\b0 " +
ObjectValue.ToString().Replace(@"\", @"\\") + @" \b0 \par}";
>
>
This is probably not be the most efficient solution, though... You should
think of using a StringBuilder and use the Append method to build the
correct RTF string...
>
--
Caio Proiete
http://www.caioproiete.com
>
>
-
>
Quote:
>Hi Caoi,
>>
>i insert is as a formated RichText, because i want a basic format for
>it. The RTF String looks like:
>>
>@"{\rtf1 {\colortbl ;\red0\green128\blue0;\red0\green0\blue255;}{\b "
>+ ObjectProperty.Name + @"} \par \b0 {" + da.Description + @"}\par {\b
>Value: }\cf1\b0 " + ObjectValue + @" \b0 \par}";
>>
>Its an excerpt from an self-made property grid, where this block is
>the part or the description pane in the lower part of the property
>gridls panel. The Problem for the Rtf-Property of the RichTextBox are
>the "\" Backslashes, since everything after it will be considered as a
>cotrol command. But there must be some way to enclose the String as a
>non Rtf string or like something "treat the string as is" inside a RFT
>string,...
>>
>Is there a way
>>
>Regards
>>
>Kerem
>>
>
>
Pavel Minaev
Guest
 
Posts: n/a
#6: Aug 29 '08

re: Displaying Text in a RichtText Control Problems,...


On Aug 29, 3:47*am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Quote:
Hi Caio,
>
Quote:
Just replace each backslash to *two* backslashes, as >do in C# when you
don't use the "@" :).
>
well, this is no real solution, since the could be a
situation were you have to backslashes and then
you will have three there.
No, that's precisely the solution. To represent a literal backslash in
RTF, you need to use the double-backslash escape, @"\\". If the source
code has two backslashes, a plain replace will never yield three - you
will have four (and the RichTextBox will correspondingly show those as
two literal backslashes).

=?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=
Guest
 
Posts: n/a
#7: Aug 29 '08

re: Displaying Text in a RichtText Control Problems,...


Hi,

thnaks for the reply. Well thats what i also found out.
The RTF Docs made this clear and my conclusion here
is, that i have to work with regular expressions to replace
everything that can be "collide" with RTF Control Codes.

Well, this is also no 100% solution, but the best so
far,...

Thanks for all the Answers,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

"Pavel Minaev" <int19h@gmail.comschrieb im Newsbeitrag
news:da794795-56bc-455a-8e44-600377b2e69c@59g2000hsb.googlegroups.com...
On Aug 29, 3:47 am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Quote:
Hi Caio,
>
Quote:
Just replace each backslash to *two* backslashes, as >do in C# when you
don't use the "@" :).
>
well, this is no real solution, since the could be a
situation were you have to backslashes and then
you will have three there.
No, that's precisely the solution. To represent a literal backslash in
RTF, you need to use the double-backslash escape, @"\\". If the source
code has two backslashes, a plain replace will never yield three - you
will have four (and the RichTextBox will correspondingly show those as
two literal backslashes).

Caio Proiete [MCT]
Guest
 
Posts: n/a
#8: Aug 29 '08

re: Displaying Text in a RichtText Control Problems,...


Hi Kerem,

I don't get it when you say this is not a 100% solution... This is the only
solution! :)

If you do a simple test, and set the Text property of a RichTextBox including
RTF Control Codes such as "\", and then check the Rtf property, you will
notice that the RichTextBox control duplicate the control codes...

Cheers,

--
Caio Proiete
http://www.caioproiete.com


-
Quote:
Hi,
>
thnaks for the reply. Well thats what i also found out.
The RTF Docs made this clear and my conclusion here
is, that i have to work with regular expressions to replace
everything that can be "collide" with RTF Control Codes.
Well, this is also no 100% solution, but the best so far,...
>
Thanks for all the Answers,...
>
Regards
>
Kerem
>
"Pavel Minaev" <int19h@gmail.comschrieb im Newsbeitrag
news:da794795-56bc-455a-8e44-600377b2e69c@59g2000hsb.googlegroups.com.
.. On Aug 29, 3:47 am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
>
Quote:
>Hi Caio,
>>
Quote:
>>Just replace each backslash to *two* backslashes, as >do in C# when
>>you don't use the "@" :).
>>>
>well, this is no real solution, since the could be a
>situation were you have to backslashes and then
>you will have three there.
No, that's precisely the solution. To represent a literal backslash in
RTF, you need to use the double-backslash escape, @"\\". If the source
code has two backslashes, a plain replace will never yield three - you
will have four (and the RichTextBox will correspondingly show those as
two literal backslashes).
>

=?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?=
Guest
 
Posts: n/a
#9: Aug 29 '08

re: Displaying Text in a RichtText Control Problems,...


Hi Caio,
Quote:
>I don't get it when you say this is not a 100% solution... This is the only
>solution! :)
yes it is and i am not saticfied with RTF anylonger so thats why
i use a GDI(+) solution. It was a wrong decision to use RTF,
because i needed several Graphics Operations that could not
be done with RTF, better to say redered,...

Thanks for you reply,...


Regards

Kerem.


--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Caio Proiete [MCT]" <caio-mspublicnews@proiete.comschrieb im Newsbeitrag
news:c69190b38398cad83831688ca2@msnews.microsoft.c om...
Quote:
Hi Kerem,
>
I don't get it when you say this is not a 100% solution... This is the
only solution! :)
>
If you do a simple test, and set the Text property of a RichTextBox
including RTF Control Codes such as "\", and then check the Rtf property,
you will notice that the RichTextBox control duplicate the control
codes...
>
Cheers,
>
--
Caio Proiete
http://www.caioproiete.com
>
>
-
>
Quote:
>Hi,
>>
>thnaks for the reply. Well thats what i also found out.
>The RTF Docs made this clear and my conclusion here
>is, that i have to work with regular expressions to replace
>everything that can be "collide" with RTF Control Codes.
>Well, this is also no 100% solution, but the best so far,...
>>
>Thanks for all the Answers,...
>>
>Regards
>>
>Kerem
>>
>"Pavel Minaev" <int19h@gmail.comschrieb im Newsbeitrag
>news:da794795-56bc-455a-8e44-600377b2e69c@59g2000hsb.googlegroups.com.
>.. On Aug 29, 3:47 am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
>>
Quote:
>>Hi Caio,
>>>
>>>Just replace each backslash to *two* backslashes, as >do in C# when
>>>you don't use the "@" :).
>>>>
>>well, this is no real solution, since the could be a
>>situation were you have to backslashes and then
>>you will have three there.
>No, that's precisely the solution. To represent a literal backslash in
>RTF, you need to use the double-backslash escape, @"\\". If the source
>code has two backslashes, a plain replace will never yield three - you
>will have four (and the RichTextBox will correspondingly show those as
>two literal backslashes).
>>
>
>
Caio Proiete [MCT]
Guest
 
Posts: n/a
#10: Aug 30 '08

re: Displaying Text in a RichtText Control Problems,...


Oh, okay :).

--
Caio Proiete
http://www.caioproiete.com


-
Quote:
Hi Caio,
>
Quote:
>I don't get it when you say this is not a 100% solution... This is
>the only solution! :)
>>
yes it is and i am not saticfied with RTF anylonger so thats why
i use a GDI(+) solution. It was a wrong decision to use RTF,
because i needed several Graphics Operations that could not
be done with RTF, better to say redered,...
Thanks for you reply,...
>
Regards
>
Kerem.
>

Pavel Minaev
Guest
 
Posts: n/a
#11: Aug 31 '08

re: Displaying Text in a RichtText Control Problems,...


On Aug 30, 2:37*am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Quote:
Hi Caio,
>
Quote:
I don't get it when you say this is not a 100% solution... This is the only
solution! :)
>
yes it is and i am not saticfied with RTF anylonger so thats why
i use a GDI(+) solution. It was a wrong decision to use RTF,
because i needed several Graphics Operations that could not
be done with RTF, better to say redered,...
>
Thanks for you reply,...
If you have some reasonably complicated text layout with inline vector
graphics, and you do not mind a dependency on 3.0, consider hosting
the WPF FlowDocument control inside your WinForms application.
Closed Thread


Similar .NET Framework bytes