i tried several things from different post, but i just cant seem to make it bold
Does anybody knows how to accomplish this?
$LabelComputer = New-Object System.Windows.Forms.Label
$LabelComputer.Text = "Computer Settings"
$LabelComputer.AutoSize = $True
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:
$LabelComputer.Font = [System.Drawing.Font]::new("Microsoft Sans Serif", 12, [System.Drawing.FontStyle]::Bold)
You’ll notice in inside that
new(...) three things:
- The name of a font
- The size of the text (you can omit this, but it will default to 1)
- 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.