Solved

Combining two RTF files to populate RichTextBox

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Json to CSV Converter - Converting large json files to csv 2 90
Need help with a query 14 55
Read top line from CSV file 14 60
Updating Printer Details in VB.Net 16 43
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 …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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