Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change a font programmatically

Tags:

c#

C# doesn't like the following code:

private void btnSizeRandom_Click(object sender, EventArgs e)
{
  btnSizeRandom.Font.Bold = true;
  btnother.Font.Bold = false;
}

Is there a way to do this programatically?

like image 597
Jim Avatar asked Jun 30 '10 20:06

Jim


1 Answers

Instances of Font are immutable. You need to construct a new Font and assign it to the Font property. The Font class has various constructors for this purpose; they copy another instance and change the style in the process.

like image 128
Tim Robinson Avatar answered Nov 07 '22 08:11

Tim Robinson