0

When I use:

Me.RichTextBox.SelectionFont = New Font(Me.RichTextBox.SelectionFont, FontStyle.Italic)

The selected text becomes italic, but when I use

lines(i - 5) = Me.Auto_Time.Text

Me.RichTextBox.Lines = lines

it saves the text from Me.Auto_Time but I lost all italic from richtextbox?

  • possible duplicate of [removing RichTextBox lines while keeping the colour of remaining lines in C#](http://stackoverflow.com/questions/7271550/removing-richtextbox-lines-while-keeping-the-colour-of-remaining-lines-in-c-shar) – Hans Passant Jul 04 '13 at 10:46
  • The property `.Text` from a TextBox only contains Text, not format. – SysDragon Jul 04 '13 at 10:46

1 Answers1

0

You need to pass the .text and then pass .rtf for formatting:

Me.RichTextBox.Lines = Lines
Me.RichTextBox.Rtf = Me.Auto_Time.Rtf
Josh Weston
  • 1,632
  • 22
  • 23
  • Yes but Me.Auto_Time.Text is text box when I used Me.RichTextBox.Lines = Lines I just lost all Italic form richtext – Gregor Bitežnik Jul 04 '13 at 12:44
  • I must have misread your question. You have a normal multiline textbox with unformatted text, and you are attempting to move this text to your RichTextBox while maintaining the formatting scheme you had in your RichTextBox? – Josh Weston Jul 04 '13 at 13:36