Results 1 to 4 of 4

Thread: [RESOLVED] Save Rich Text Box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    Resolved [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

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Save Rich Text Box

    To save formatted text, read the property Rtf instead of Text



  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    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

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    198

    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
  •  



Click Here to Expand Forum to Full Width