0
votes

I have the following code

TextBox1.Text = "Two of the peak human experiences are "
    TextBox1.Text = TextBox1.Text & "good food and classical music."
     TextBox1.FontSize = "16"

It shows two lines in the same text box . How would I change the font size for each line of text and have them appear in the same textbox?

2

2 Answers

4
votes

Use a richtextbox instead.

richTextBox1.SelectionFont = new Font("Arial", 12, FontStyle.Bold);
richTextBox1.AppendText("Two of the peak human experiences are");
richTextBox1.SelectionFont = new Font("Tahoma", 16, FontStyle.Bold);
richTextBox1.AppendText("good food and classical music");
0
votes

You can't do that with a TextBox but you can use a RichTextBox:

<RichTextBox>
    <RichTextBox.Resources>
      <Style x:Key="Bigger">
        <Setter Property="FontSize" Value="16"/>
      </Style>
    </RichTextBox.Resources>
    <FlowDocument>
      <Paragraph>
        This is the first paragraph.
      </Paragraph>
      <Paragraph Style={StaticResource Bigger}>
        This is the second paragraph.
      </Paragraph>
    </FlowDocument>
  </RichTextBox>