简体   繁体   English

更改TextBox中的字体样式

[英]Change a font style in a TextBox

I have several text box's where input is added. 我有几个文本框,其中添加了输入。 All these input are then displayed in a text box at the bottom of the program after the button is clicked. 所有这些输入都会在单击按钮后显示在程序底部的文本框中。

I want to make the just one of those strings to display as italics in the text box at the bottom of the program. 我想让这些字符串中的一个在程序底部的文本框中显示为斜体。

Here is what I have. 这就是我所拥有的。

private void button1_Click(object sender, EventArgs e) { string author; private void button1_Click(object sender,EventArgs e){string author; string name; 字符串名称; string year; 弦年; string title; 字符串标题; string place; 串位; string publisher; 字符串出版商

        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;

    }

What i want is to display the title string in italics. 我想要的是以斜体显示标题字符串。

Any help would be great. 任何帮助都会很棒。 Thanks 谢谢

richTextBox1.Find(title, RichTextBoxFinds.MatchCase);
richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Italic);

That should italicize the title of the book and only the title of the book, while keeping the font the same as the rest of the rich text box. 这应该保持书的标题和书的标题,同时保持字体与富文本框的其余部分相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM