Bold text if checkbox = checked

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
User avatar
localpct
Posts: 320
Joined: Wed Sep 09, 2015 12:53 pm

Bold text if checkbox = checked

Post by localpct »

i tried to ask on this post but its too old https://www.sapien.com/forums/viewtopic.php?f=21&t=7620&p=37750&hilit=Font+change#p37750

im creating an app that scans a computer lets say my threshold for a folder is 200 MB and it finds one that is 220. I want it to check the box (done), change the text to red ( done ) and bold so it stands out but everything I've tried for the last several hours is not working.

User avatar
SAPIEN Support Forums
Posts: 945
Joined: Wed Dec 03, 2014 2:26 pm

Bold text if checkbox = checked

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, localpct.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

jvierra
Posts: 14621
Joined: Tue May 22, 2007 9:57 am
Answers: 3
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Bold text if checkbox = checked

Post by jvierra »

What is it you are asking. What check box? What do you want to highlight?

User avatar
localpct
Posts: 320
Joined: Wed Sep 09, 2015 12:53 pm

Re: Bold text if checkbox = checked

Post by localpct »

Imagine a form with 10 checkboxes
Each of those check boxes have text the the right for example
Hard Drive Space
Size of SCCM Folder
Size of wintemp folder
Etc...

I press go and it runs through the script, if an item passes my threshold, it stays unchecked, font turns green and no bolding. Now let's say my threshold for my Hard Disk Space is 20 gigs free and it has 18 Gigs free. I want the checkbox to check itself, font color to turn red ( both of these Ive figured out ) and the font to turn bold so a technician can quickly look at the form and know what passed and what didn't.

Makes sense?

jvierra
Posts: 14621
Joined: Tue May 22, 2007 9:57 am
Answers: 3
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Bold text if checkbox = checked

Post by jvierra »

I can suggest a good stating place to learn how to build a form.

These articles will get you started.


https://www.sapien.com/blog/topics/user ... istrators/

https://www.sapien.com/blog/topics/spo ... -controls/

User avatar
dan.potter
Posts: 709
Joined: Wed Oct 08, 2014 6:02 am

Re: Bold text if checkbox = checked

Post by dan.potter »

localpct wrote:Imagine a form with 10 checkboxes
Each of those check boxes have text the the right for example
Hard Drive Space
Size of SCCM Folder
Size of wintemp folder
Etc...

I press go and it runs through the script, if an item passes my threshold, it stays unchecked, font turns green and no bolding. Now let's say my threshold for my Hard Disk Space is 20 gigs free and it has 18 Gigs free. I want the checkbox to check itself, font color to turn red ( both of these Ive figured out ) and the font to turn bold so a technician can quickly look at the form and know what passed and what didn't.

Makes sense?
My preference is to use label images and the image list control. You can easily find icons on the internet like a green check or red x.

Based on the condition assign the image to the label.
PowerShell Code
Double-click the code block to select all.
if (($checkc.size/1gb -gt $cdrive) -and ($checkd.size/1gb -gt $ddrive) -and ($checke.size/1gb -gt $edrive)) {
			$labelDriveSpecs.ImageIndex = 0
		} else { $labelDriveSpecs.ImageIndex = 1

User avatar
localpct
Posts: 320
Joined: Wed Sep 09, 2015 12:53 pm

Re: Bold text if checkbox = checked

Post by localpct »

Thanks for the help!

Does it matter if the image is an .ico or .png etc??

When I try your script and I've defined both
$cdrive and $checkC if I just use text it's fine but if I use an image I get

The property 'ImageIndex' cannot be found on this object. Verify that the property exists and can be set.
Attachments
PCHEALTHsendout.psf
(637.29 KiB) Downloaded 107 times

User avatar
localpct
Posts: 320
Joined: Wed Sep 09, 2015 12:53 pm

Re: Bold text if checkbox = checked

Post by localpct »

I have a feeling I'm just setting a value wrong. I'm not just looking for answers as I don't believe this is too hard of a problem.

jvierra
Posts: 14621
Joined: Tue May 22, 2007 9:57 am
Answers: 3
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Bold text if checkbox = checked

Post by jvierra »

Checkboxes don't have images.

jvierra
Posts: 14621
Joined: Tue May 22, 2007 9:57 am
Answers: 3
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Bold text if checkbox = checked

Post by jvierra »

You are setting the "imageList" control on the image collection and not on the label control

Part of the cause of this is that you have named the ImageList control as "labelDriveSpecs" when it has nothing to do with labels or drives.

Locked