-
Jan 11th, 2012, 01:09 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Save Rich Text Box
Currently using code below on a button click event to save the contents of a rich text box:
Code:
tbMix.Text = IO.Path.Combine(tbFileName2.Text, _
IO.Path.ChangeExtension(String.Join("", tbScriptName.Text.Where(Function(TheChar As Char, TakeVar As Boolean) _
Not IO.Path.GetInvalidPathChars.Contains(TheChar)).ToList), ".doc"))
Dim objwriter As New System.IO.StreamWriter(tbMix.Text)
objwriter.Write(tbUpperBody.Text)
objwriter.Close()
tbMix combines the text of tbFileName2 and tbScriptName to create a file path which is the file that the rich text box is created to.
however, when i format things in the rich text box, eg as bold etc, and then reopen the contents of the file, the formatting has not been saved.
why is this? can anyone solve the problem?
thanks
-
Jan 11th, 2012, 01:46 PM
#2
Re: Save Rich Text Box
To save formatted text, read the property Rtf instead of Text
-
Jan 11th, 2012, 02:02 PM
#3
Thread Starter
Addicted Member
Re: Save Rich Text Box
Hi there, thanks for reply...
could you expand a bit? i changed the
Code:
objwriter.Write(tbUpperBody.Text)
line to
Code:
objwriter.Write(tbUpperBody.Rtf)
**tbUpperBody is my RichTextBox.
However, when I reopen the file, it still hasn't stored the bold formatting.
Thanks for your time and help
-
Jan 11th, 2012, 02:07 PM
#4
Thread Starter
Addicted Member
Re: Save Rich Text Box
SORRY** it was my mistake, ive sorted it now.. many thanks indeed!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|