Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 400
  • Last Modified:

Combining two RTF files to populate RichTextBox

I've looked at a number of postings about doing this, but upon populating my RichTextBox it only shows the contents of the first RTF file.  Basically I'm attempting to populate the body of my custom email form with text and an email signature created inside my app.

                    txtBody.LoadFile("My.Resources.BodyText.rtf")
                    Dim xRTF As New RichTextBox
                    xRTF.LoadFile("My.Resources.Signature.rtf")
                    txtBody.SelectionStart = txtBody.TextLength
                    txtBody.SelectedRtf = xRTF.SelectedRtf

What would be even better would be to have BodyText come from a text field in a table with no formatting, format it to MS Sans Serif, 11pt, and add my signature to it.  That would probably be asking too much.


Thanks in advance.
0
TSFLLC
Asked:
TSFLLC
  • 2
1 Solution
 
BuggyCoderCommented:
Simple and straight forward example:-
string strBody=File.ReadAllLines("filepath");
string strSig = File.ReadAllLines("filePath");

xRTF.Text = strBody + Environment.NewLine  + strSig;

Open in new window

0
 
TSFLLCAuthor Commented:
Buggy,

Is your example based on the last thing I wrote about field text or is it supposed to be based on the use of RTF files?

If the 'filepath' is suppose to be RTF files, I'm getting an error 'Operator + is not defined for type 'String' and 'System.Array'.  I see that your examples are C#.  Not knowing C# I'm assuming string strBody=....then the VB equivalent would be 'Dim strBody as String = File.ReadAll.....'

ReadAllLines is returning an 1-dimensional array.  Can you clarify?
0
 
CodeCruiserCommented:
You need to add

xRTF.SelectAll()

before

txtBody.SelectedRtf = xRTF.SelectedRtf

line.
0
 
TSFLLCAuthor Commented:
Thanks CodeCruiser.  That's what I needed.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now