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.
This topic is 8 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

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
Last visit: Thu Oct 22, 2015 1:10 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 397
Last visit: Thu Oct 27, 2022 5:57 am

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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
Last visit: Wed Nov 14, 2018 11:39 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: 397
Last visit: Thu Oct 27, 2022 5:57 am

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 171 times
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Bold text if checkbox = checked

Post by jvierra »

Checkboxes don't have images.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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.
This topic is 8 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked