Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Combining two RTF files to populate RichTextBox

Posted on 2012-03-21
4
Medium Priority
?
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37751165
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
ID: 37752187
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 2000 total points
ID: 37765225
You need to add

xRTF.SelectAll()

before

txtBody.SelectedRtf = xRTF.SelectedRtf

line.
0
 

Author Closing Comment

by:TSFLLC
ID: 37766191
Thanks CodeCruiser.  That's what I needed.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

704 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