Hi,
Hope this is a simple question: how do I set a single font in a label to a different color and font?
I would like to set a label with text "Add users/groups/computer$" with the $ in red and in fat.
J.
Label: howto set 1 letter in other color andfo
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Label: howto set 1 letter in other color andfo
That isn't possible, a label can only have one color. If you wish to have two colors then you will need two labels.
viewtopic.php?t=10424
viewtopic.php?t=10424
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Label: howto set 1 letter in other color andfo
You can use the "Paint" event to create almost any graphic form you want including a multi-color label text.
Here is a quick lesson on graphics and how to "paint" graphics using PowerShell:
http://www.techotopia.com/index.php/Dra ... and_GDI%2B
With a control just grab the $_.Graphics object and use the methods to write your text in any color or image you like.
Here is a quick lesson on graphics and how to "paint" graphics using PowerShell:
http://www.techotopia.com/index.php/Dra ... and_GDI%2B
With a control just grab the $_.Graphics object and use the methods to write your text in any color or image you like.
Code: Select all
$label1_Paint=[System.Windows.Forms.PaintEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]
$this.Text = ''
$font = [System.Drawing.Font]'Microsoft Sans Serif, 13.8pt, style=Bold, Italic'
$brush = [System.Drawing.Brushes]::Red
$_.Graphics.DrawString('$',$font ,$brush,2,2)
$brush = [System.Drawing.Brushes]::DarkGreen
$_.Graphics.DrawString('Whoopie', $font, $brush, 21, 2)
}