Rtf and variable

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

Hi,
How can I assign the content of a string variable to the Rtf property
of a richtextbox :

Dim message As String = txtMessage.Rtf & "[" &
DirectCast(lstFields.SelectedItem, Field).FieldName & "]"
txtMessage.Rtf = "{\rtf1\ansi message}"

This displays 'message' instead of its content :(

Thx
 
oh ! it was that simple ? thx !
By any luck, do you know how to append text in a richtextbox ?
Something like :

Dim message As String = txtMessage.Rtf & "[" &
DirectCast(lstFields.SelectedItem, Field).FieldName & "]"
txtMessage.Rtf = "{\rtf1\ansi
{\colortbl;\red0\green0\blue0;\red255\green0\blue0;} \cf2" & message &
"\cf1}"

That doesn't work :(
 
Now I have another problem :
txtMessage.Rtf = "{\rtf1\ansi
{\colortbl;\red0\green0\blue0;\red0\green200\blue0;}" & txtMessage.Text
& "\cf2" & message & "\cf0}"

In the above, the color of 'message' is green but then the text that
one types afterward should be black again as I do & "\cf0}". But
instead the text remains always green. Why ?
 
also, the following has no effect at all on my text :
txtMessage.SelectionColor = Color.Red
txtMessage.Select(iCntr, 2)

the text is not selected and there's no color change,
can you help ?
 
I've found out what's going on,
iCntr was based on my message lenght, but that was comprising all the
Rtf stuff before my actual text. Now iCntr is correct and the text is
selected properly. However it is not red.... why ?
 
I've found out what's going on,
iCntr was based on my message lenght, but that was comprising all the
Rtf stuff before my actual text. Now iCntr is correct and the text is
selected properly. However it is not red.... why ?
 

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

Back
Top