How to underline (with Bold & italics) a string/text assigned Control.Text property in C# windows application programmatically?
Control provides property "Font". You can assign this by using the existing Font as prototype and define the desired style information.
This snippet makes all fonts of all top controls bold, underlined and italic:
foreach (Control item in this.Controls)
{
item.Font =
new Font
(
item.Font,
FontStyle.Underline | FontStyle.Bold | FontStyle.Italic
);
}
Flo
You want the Font property.
You can't set the underline of the Font along with the other properties - as they're read only - so you'll need to create a new Font object and assign that to the Font property. There are several constructors that take the bold, italic & underline properties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With