Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to create a RichTextFile?

How to create a RichTextFile?

Scheduled Pinned Locked Moved Visual Basic
questiongraphicstutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dac9901
    wrote on last edited by
    #1

    Hello Everyone, I am using a RichTextBox to display text and graphics. I know how to load a previously created rtf file(rtb1.LoadFile(FileName, RichTextBoxStreamType.RichText)), but how do I create the rtf file. I using the RichTextBox for read-only purposes. I don't want the user to add or change anything in the RichTextBox. I am not sure how to print and add pictures to a RTF file. If I was creating a text file I would use the "Printline" command. Also, I want to use special formatting like Bold and different font sizes when I create my RTF file. Any Ideas?:confused:

    C 1 Reply Last reply
    0
    • D dac9901

      Hello Everyone, I am using a RichTextBox to display text and graphics. I know how to load a previously created rtf file(rtb1.LoadFile(FileName, RichTextBoxStreamType.RichText)), but how do I create the rtf file. I using the RichTextBox for read-only purposes. I don't want the user to add or change anything in the RichTextBox. I am not sure how to print and add pictures to a RTF file. If I was creating a text file I would use the "Printline" command. Also, I want to use special formatting like Bold and different font sizes when I create my RTF file. Any Ideas?:confused:

      C Offline
      C Offline
      Chatura Dilan
      wrote on last edited by
      #2

      This is one idea;) You can print RichTextBox contents http://support.microsoft.com/default.aspx?scid=kb;en-us;811401 And you can use RichTextBox.SaveFile("path & yourfile.rtf") to create it

      Regards,

      Chatura Dilan

      H 1 Reply Last reply
      0
      • C Chatura Dilan

        This is one idea;) You can print RichTextBox contents http://support.microsoft.com/default.aspx?scid=kb;en-us;811401 And you can use RichTextBox.SaveFile("path & yourfile.rtf") to create it

        Regards,

        Chatura Dilan

        H Offline
        H Offline
        hannesHTG
        wrote on last edited by
        #3

        OK, fistly I don't know how to attach files here, if at all possible. To Save RTF Files, you could try : RichTextBox1.SaveFile(sfMW.FileName, RichTextBoxStreamType.RichText) For Bold, Italic and Underline, here's a Nice Sub you could use : Private Sub ToggleStyle(ByVal style As FontStyle) 'style option1 Me.rtbMW.SelectionFont = New Font(rtbMW.SelectionFont, rtbMW.SelectionFont.Style Xor style) End Sub Then, you could just call it like : ToggleStyle(FontStyle.Underline) 'underline ToggleStyle(FontStyle.Bold) 'Bold ToggleStyle(FontStyle.Italic) "Italic The benefit here, is that the selected Font will remain the same when Formatting is applied. For alignment : RichTexBox1.SelectionAlignment = HorizontalAlignment.Left RichTexBox1.SelectionAlignment = HorizontalAlignment.Center RichTexBox1.SelectionAlignment = HorizontalAlignment.Right Hope it helps! H T G

        D 1 Reply Last reply
        0
        • H hannesHTG

          OK, fistly I don't know how to attach files here, if at all possible. To Save RTF Files, you could try : RichTextBox1.SaveFile(sfMW.FileName, RichTextBoxStreamType.RichText) For Bold, Italic and Underline, here's a Nice Sub you could use : Private Sub ToggleStyle(ByVal style As FontStyle) 'style option1 Me.rtbMW.SelectionFont = New Font(rtbMW.SelectionFont, rtbMW.SelectionFont.Style Xor style) End Sub Then, you could just call it like : ToggleStyle(FontStyle.Underline) 'underline ToggleStyle(FontStyle.Bold) 'Bold ToggleStyle(FontStyle.Italic) "Italic The benefit here, is that the selected Font will remain the same when Formatting is applied. For alignment : RichTexBox1.SelectionAlignment = HorizontalAlignment.Left RichTexBox1.SelectionAlignment = HorizontalAlignment.Center RichTexBox1.SelectionAlignment = HorizontalAlignment.Right Hope it helps! H T G

          D Offline
          D Offline
          dac9901
          wrote on last edited by
          #4

          How do I go about adding several lines of text to the RichTextBox? I can use rtb.text = "Text in a richtextbox" or I can use rtb.appendtext("This text is appended to the original text"). I have been using the Print and Printline statements for plain text files but for a RichTextBox what should I use? Thanks for all of your help.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups