简体   繁体   中英

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; 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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