Displaying Text in a RichtText Control Problems,...

K

Kerem Gümrükcü

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


--
 
C

Caio Proiete [MCT]

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
 
K

Kerem Gümrükcü

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
 
C

Caio Proiete [MCT]

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


-
 
K

Kerem Gümrükcü

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

Pavel Minaev

Hi Caio,


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).
 
K

Kerem Gümrükcü

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

Hi Caio,


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).
 
C

Caio Proiete [MCT]

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


-
 
K

Kerem Gümrükcü

Hi Caio,
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
 
P

Pavel Minaev

Hi Caio,


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.
 

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