I have a 3 checkboxes and a sub that handles all 3 of their CheckChanged events. Basically I need to prevent them from unchecking ALL as at least 1 needs to be checked. When they uncheck the lasted checked box it will give a messagebox stating they need to select at least 1, and i want it to recheck the one they just unchecked. I imagine I would be able to reference it via the sender object passed in, but I am having a hard time figuring out how to reference this to the checkbox itself?
I got this code to work, but im not sure if I NEED to actually create a new object to accomplish this
is this efficient?VB Code:
MessageBox.Show("At least 1 checkbox must be checked", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error) Dim MyCheck As New CheckBox MyCheck = CType(sender, CheckBox) MyCheck.Checked = True MyCheck = Nothing




Reply With Quote