In my application different things happen when you check or uncheck a checkbox. However when initializing the checkbox, it also triggers the event. I would like to disable the triggering of the event at a point in time when i reset the state of the checkbox. I guess I am asking how to i disable and re-enable triggering as I apply:
$checkboxSelectedProgram.checked = $false
Perhaps it is a simple as a command before and after the command above.
thanks,
John
uncheck a check with a command and not trigger an event
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.
- jsira2003@yahoo.com
- Posts: 117
- Last visit: Tue Jul 11, 2023 6:18 am
Re: uncheck a check with a command and not trigger an event
Is this what you are asking?
- Attachments
-
- Test-CBChanged2.psf
- (31.77 KiB) Downloaded 152 times
- jsira2003@yahoo.com
- Posts: 117
- Last visit: Tue Jul 11, 2023 6:18 am
Re: uncheck a check with a command and not trigger an event
When you click on a check box on a windows form that is an event. There are times when I want to change the state of the checkbox to unchecked without triggering an event. This seems straight forward. I found that by applying the command $checkboxselectedprogram.checked = $false , this triggers an uncheck event. I want to apply the command above and not trigger an event. I believe I have expressed myself clearly.
- jsira2003@yahoo.com
- Posts: 117
- Last visit: Tue Jul 11, 2023 6:18 am
Re: uncheck a check with a command and not trigger an event
$checkboxSelectedProgram.Enabled = $false
#change the state undetected since checkbox is disabled.
$checkboxSelectedProgram.Checked = $false
$checkboxSelectedProgram.refresh()
$checkboxSelectedProgram.Enabled = $true
This is the answer. I figured out it should be something simple like this.
John
#change the state undetected since checkbox is disabled.
$checkboxSelectedProgram.Checked = $false
$checkboxSelectedProgram.refresh()
$checkboxSelectedProgram.Enabled = $true
This is the answer. I figured out it should be something simple like this.
John
Re: uncheck a check with a command and not trigger an event
Disabling a checkbox does not disable events. It only disables the UI. Look at my same. The answer is much easier than you think.
Also - "Refresh()" is not necessary.
Also - "Refresh()" is not necessary.
Code: Select all
$checkbox1_CheckedChanged={
if(-not $setting){
Write-Host 'changed'
}
}
$safeSetting_Click={
$setting = $true
$checkbox1.Checked = -not $checkbox1.Checked
$setting = $false
}