Solved

Combining two RTF files to populate RichTextBox

Posted on 2012-03-21
4
382 Views
Last Modified: 2012-06-21
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
Comment
Question by:TSFLLC
  • 2
4 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
Comment Utility
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
 

Author Comment

by:TSFLLC
Comment Utility
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
You need to add

xRTF.SelectAll()

before

txtBody.SelectedRtf = xRTF.SelectedRtf

line.
0
 

Author Closing Comment

by:TSFLLC
Comment Utility
Thanks CodeCruiser.  That's what I needed.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now