Simplest way, at the end of your event handler you iterate through all elements in the list. Add 1 to counter if an item is checked.
Once you iterated through all items and your counter is still zero, you know nothing is checked.
At that point you can:
A) Simply re-check the item that was clicked on
B) Check whatever is considered the default item
C) Show a messagebox with a world ending error message and crash gracefully.
Since you using a list rather than a group of radio buttons I assume you want this to be expandable. I would suggest, which is not much of a change, to just use a plain list box. No checkboxes.
In single selection mode (SelectionMode = One), once you select the first item programmatically when the form is created, the user can never unselect all items. He can only click on another choice to select it. He cannot click on a selected item to unselect it.
Once you iterated through all items and your counter is still zero, you know nothing is checked.
At that point you can:
A) Simply re-check the item that was clicked on
B) Check whatever is considered the default item
C) Show a messagebox with a world ending error message and crash gracefully.
Since you using a list rather than a group of radio buttons I assume you want this to be expandable. I would suggest, which is not much of a change, to just use a plain list box. No checkboxes.
In single selection mode (SelectionMode = One), once you select the first item programmatically when the form is created, the user can never unselect all items. He can only click on another choice to select it. He cannot click on a selected item to unselect it.
Code:
$form1_Load={
Update-ListBox $listbox1 "Option 1", "Option 2", "Option 3"
$listbox1.SelectedIndex = 0
}
Statistics: Posted by Alexander Riedel — Mon Apr 01, 2024 11:16 pm