I have a checkbox that when a user un-checks the code will do some checks and then give the User a message box question making sure that they wish to untick this box. On a No i would like the Sub routine to end and the box go back to ticked.
I have used e.cancel or e.handled = false in the past to stop an action happening to a control but in this case it says that e.cancel is not a member of EventArgs.
Any idea why e.cancel isn't working for my checkboxes?
Private Sub CheckChange(sender As Object, e As EventArgs) Handles chkMonday.CheckedChanged, chkTuesday.CheckedChanged, chkWednesday.CheckedChanged, chkThursday.CheckedChanged, chkFriday.CheckedChanged
If blLoadingWeek = False Then
Dim tbControl As CheckBox = DirectCast(sender, CheckBox)
If Today() > dtelockingDate Or (Today() = dtelockingDate And TimeOfDay >= "12:00") Then
If tbControl.Checked = False Then
If MsgBox("If you remove this booking you will lose this parking space and will not be able to rebook it. Do you wish to continue?", vbYesNo, "Removing Booking") = vbNo Then
e.cancel
'tbControl.Checked = True - Causes this routine to trigger again.
End If
Else
MessageBox.Show("The cut off date of bookings spaces for this week has past. You cannot book a space for this day.")
End If
End If
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire