Reputation: 786
Trying to change Font Style to Underline for 1 line,and printing next line in Regular Style is not working for me. I am trying something like this:-
textBox1.Font = new Font(textBox1.Font, FontStyle.Underline);
textBox1.Text+="This line should be underlined";
textBox1.Font = new Font(textBox1.Font, FontStyle.Regular);
textBox1.Text+=Environment.NewLine;
textBox1.Text+="This line should be normal";
But everything is coming only as it is done in the last line affecting FontStyle,in this case Regular. If I remove 3rd line,everything comes underline.
Upvotes: 0
Views: 3637
Reputation: 20720
A normal TextBox
usually just supports one style. Its value is just a string, not a string with formatting information.
Instead, use a RichTextBox
(WinForms)/RichTextBox
(WPF).
Upvotes: 1