Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Text(String) in Bold and write into a RichTextBox 1

Status
Not open for further replies.

mveera

Programmer
Nov 6, 2002
81
US
Hi,

I am using a RichTextBox to create a memo text. When the user clicks the memo button, it will open a form with text in the richtextbox. in this form the user will be able to modify the font style, make it bold etc., But is it possible to write a text into the Richtextbox in Bold, so that the user need not do it everytime. i tried going thru' the RTF specifications, and tried using the \b before the text and ending with \b0, but it is not working. I am using selRTF to write into the Richtextbox.

Thanks
Veera
 
You need a space after each code, e.g. "\b ". Make sure it's there!
Rob
 
Hi,

This is what i use
strText = strText & "\par " & "\b " & " Renewal Factors: " & " \b0 " & Chr(13) & Chr(13)
t what this does is write \par \b in the richtextbox instead of formatting. Should the \ be written in any format.

Thanks
Veera
 
Hmmm... that should work. I noticed in my code I usually, when adding a paragraph, will use
strText = strText & chr(13) & chr(10) & "\par ...."
I'm not sure anymore why I do that, but it's worth trying to add the CrLf before the \par
Rob
 
Hi,

I think its not working.

I use the same code as what u gave.

rtbMemo.Text = ""
rtbMemo.SelRTF = " " & Chr(13) & Chr(10) & "\par \b Testing Bold Proeprty \b0"

This i do it on form activate.

This displays "\par \b Testing Bold Proeprty \b0" in the richtext box.

Anyother property we will have to set for the richtextbox?

Thanks
Veera
 
I haven't looked into this recently, but I use the TextRTF property, not the SelRTF property. Worth trying, once again.
Rob
 
I looked into that, and it should work fine with your SelRTF. You said the user formatting works fine - I would go and create what you want to do programmatically by using the user interface, and then read out the TextRTF property and compare it with your programmatic approach. Would that be possible?
Rob
 
Here is a valid content of a RichTextBox that I've created programmatically:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman Bookman Old Style;}}
\viewkind4\uc1\pard\f0\fs20 Import raw data from a .DBF file
\par }

Note the {} brackets around the whole thing, and also the CrLf before the \par. I don't know if this helps, but it may give you a hint...
Rob
 
Hi,

I think i have gone a little out of loop here.

So if construct a string with the value

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman Bookman Old Style;}}
\viewkind4\uc1\pard\f0\fs20 Import raw data from a .DBF file
\par }

and use selRTF or textRTF to set the text in richtextbox at run time the richtextbox will display
Import raw data from a .DBF file.

b'cos what i get is the string itself and not the formatted text.

Sorry if i am confusing you.

This is the exact requirement
say i have first name and last name in the form. when the user enters the values and presses a button, another form will open up which contains a richtext box. Here i should show the values entered by the user with some sections in BOLD or anyother style.
Is this possible to achieve?

Thank You
Veera
 
Yup, I get the formatted text. Just to make sure we're on the same page, could you tell me what

rtbMemo.TextRTF = "{" & Chr(13) & Chr(10) & "\par \b Testing Bold Property \b0}"

does in your case? I just tested it on my end, and it works fine.
Rob

Rob
[flowerface]
 
Thanks Rob,

It worked. All these i have been trying without the opening braces b'cos, i thought it was not necessary as i am loading a template rtf file before the text is appended. since the template rtf file has the braces i thought it was required.

Anyway with the braces it works fine and Thank You very much for the help.

Thanks
Veera
 
Er:

rbMemo.SelBold = True
rbMemo.SelText = "Testing bold property"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top