Solved

Combining two RTF files to populate RichTextBox

Posted on 2012-03-21
4
393 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 500 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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