With the CheckListBox in VB.NET in VS2005, how would you make it compulsory that at least one item is selected?
Can you select one of the items at design time to make it the default?
What would be best way to handle the validation part of this scenario? When should the user be required to tick one of the boxes?
Either idea — preventing the user from unchecking the last checked item, or validating that at least one item is checked before proceeding — is fairly straightforward to implement.
How to prevent the user from unchecking the last checked item
1. Make sure at least one item is checked to begin with (e.g., in your form’s
Loadevent):2. Add some simple logic to your
ItemCheckevent handler:How to validate that at least one item is checked