-2

I have a TextBox that shows text in italic, but when it is displayed in a RichTextBox, the text becomes regular.

Example: Richtextbox1.text = textBox1.text

textBox1 is italic, but when showed in the RichTextBox the font become regular!

How to keep it italic ?

Blackwood
  • 4,504
  • 16
  • 32
  • 41
  • 1
    A TextBox is not the same as a RichTextBox. A TextBox contains a string (stored in the Text property) and a font (stored in the Font property) and the font is used to display the entire string (you cant use different formats for different parts of the string. A RichTextBox has an Rtf property that allows you to include formatting information in the string that provides the text to be displayed. – Blackwood Aug 24 '18 at 02:20
  • Well, how to maintain the same italic string when it is printed to another textbox ? – Edeb Education Aug 24 '18 at 02:27
  • Presumably you already know that you applied italic formatting to that TextBox, so when you copy the text from that TextBox, apply italic formatting to the text when you place it in the RichTextBox. See the [documentation for RichTextBox](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.richtextbox?view=netframework-4.7) for more information, or see the answer to this question for an example: https://stackoverflow.com/questions/5362957/visual-basic-richtextbox-setting-specific-text-to-italic-font-style – Blackwood Aug 24 '18 at 02:40

1 Answers1

0

Just assign not only the text but the font also.

RichTextBox1.Text = TextBox1.Text
RichTextBox1.Font = TextBox1.Font
Mary
  • 14,926
  • 3
  • 18
  • 27