【问题标题】:Change a font style in a TextBox更改 TextBox 中的字体样式
【发布时间】:2011-12-02 11:16:09
【问题描述】:

我有几个添加输入的文本框。点击按钮后,所有这些输入都会显示在程序底部的文本框中。

我想让其中一个字符串在程序底部的文本框中显示为斜体。

这就是我所拥有的。

private void button1_Click(object sender, EventArgs e) { 字符串作者; 字符串名称; 字符串年份; 字符串标题; 字符串的地方; 字符串发布者;

        name = textBox2.Text + ", ";
        author = textBox1.Text + ". ";
        year =  "(" + textBox3.Text + ") ";
        title = textBox4.Text + ", ";
        place = textBox5.Text + ", ";
        publisher = textBox6.Text + ".";


        // output to reference field


        richTextBox1.Text = name + author + year + title + place + publisher;

    }

我想要的是用斜体显示标题字符串。

任何帮助都会很棒。 谢谢

【问题讨论】:

    标签: c#


    【解决方案1】:
    richTextBox1.Find(title, RichTextBoxFinds.MatchCase);
    richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Italic);
    

    这应该使书名和书名斜体,同时保持字体与富文本框的其余部分相同。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-22
      • 1970-01-01
      相关资源
      最近更新 更多