Hi,
if a user run's my GUI Project it should be possible that the user change some preferences. Therefore i create an empty form where i placed some checkboxes and two buttons (Apply / Close). The apply button should call an event or function to collect the state of each checkbox an write them in a file. At the startup of running the Project it should be read in from the file.
Now my problem is to collect all states of the checkboxes without the need to call the checkbox element direct. In my opinion it should be possible to ask the running project for all checkbox elements in it's form to create a loop that save the checkbox state in a file. Same one to read the file an set the checkbox state at startup.
Save Checkbox state in a file
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: Save Checkbox state in a file
Hi
this one i save it in an array and then in a file. If i open the GUI i want to load the file and set the checkbox checked state.
Now my problem is that i read in the file and my array says that checked is a System.String. If i say it should be bool - no change will be done. So i could not set the checkbox state like $checkbox1.checked = $true. With my problem it would be say $checkbox1.checken = true. Is it possible to convert it from System.String to Boolean.
Code: Select all
$form.Controls | Where{ $_.GetType().Name -eq 'CheckBox'} | Select Name, Text, Checked
Now my problem is that i read in the file and my array says that checked is a System.String. If i say it should be bool - no change will be done. So i could not set the checkbox state like $checkbox1.checked = $true. With my problem it would be say $checkbox1.checken = true. Is it possible to convert it from System.String to Boolean.
Re: Save Checkbox state in a file
Save it like this:
Code: Select all
$form.Controls | Where{ $_.GetType().Name -eq 'CheckBox'} | Select Name, Text, @{n='Checked';e={[int]$_.Checked}}