Dont know how to add bold to a label in winforms powershell

Question:

i tried several things from different post, but i just cant seem to make it bold

Does anybody knows how to accomplish this?

Answer:

You’re going to need to create a Font object and give that to the Font property on your label control.

Unfortunately with these objects you need to give it a few things in the constructor, so you can’t just create a blank object and fill it with details like you can with the label.

To that end you can do this before adding the control to your form:

You’ll notice in inside that new(...) three things:

  1. The name of a font
  2. The size of the text (you can omit this, but it will default to 1)
  3. The font style, in this case bold.

You’ll need to adjust the Font and Size to fit your needs.

Note, if you’re creating many labels using the same font, create your font object and assign it to $LabelFont then your property on the label can be $LabelComputer.Font = $LabelFont.

Source:

Dont know how to add bold to a label in winforms powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply