0

我有以下代码

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

它在同一个文本框中显示两行。如何更改每行文本的字体大小并使它们出现在同一个文本框中?

4

2 回答 2

4

请改用富文本框。

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");
于 2013-07-24T02:46:53.117 回答
0

你不能用 TextBox 做到这一点,但你可以使用 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>
于 2013-07-24T02:47:46.200 回答