Visual Basic:
Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
If MonthCalendar1.SelectionStart > MonthCalendar1.TodayDate Then
MsgBox("Date cannot be greater than today date")
MonthCalendar1.Visible = True
MonthCalendar1.Focus()
Else
MonthCalendar1.Visible = False
per_dob.Text = MonthCalendar1.SelectionStart
End If
End Sub
Private Sub MonthCalendar1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MonthCalendar1.Leave
If MonthCalendar1.Visible = True Then
MsgBox("Please close the calendar")
End If
End Sub
In the above code when i select the date i make the monthcalendar visible=false. Still i get the msg "Please close the calendar" when the date is selected. Could anyone please tell me where i have gone wrong. I get the msgbox displayed sometimes. How to avoid that.