Can’t seem to find an easy answer but I am looking for how I would setup a Checkbox that when unchecked it runs a command and when it is checked it runs a command.
I have it populate a txt file with some data when its checked but I want to have it clear that data when I uncheck the box.
This is accomplished via the -OnChange handler and the $EventData variable. The below should accomplish what you’re looking for:
New-UDCheckbox -Label 'My Test CheckBox' -OnChange {
if($EventData) {
# If the CheckBox is checked, Do this Stuff
} else {
# If the CheckBox is unchecked, do this stuff
}
}
I know this question has been answered, but I only just seen it. So just wanted to chip in, that on the ‘new’ default dashboard on the nightly builds, Adam has been kind enough to provide a load of examples with code of UI controls so for your question there is an example:-