How to create a RichTextFile?
-
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:
-
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:
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
-
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
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
-
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
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.