开发者

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; string name; 开发者_JS百科 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜