zy_abc Posted May 20, 2003 Posted May 20, 2003 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. Quote Thanks & Regards, zy_abc
Administrators PlausiblyDamp Posted May 20, 2003 Administrators Posted May 20, 2003 The problem seems to be that setting the MonthCalendar1.visible = false causes the MonthCalendar1_Leave event to be fired, how are you using this calendar (as a pop-up windows or as part of a form?) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
zy_abc Posted May 20, 2003 Author Posted May 20, 2003 Thks for the reply. It is a part of the form. When a button is clicked the monthcalendar is made is visible. If the date selected is correct i want to hide the monthcalendar. if the user opens the monthcalendar and tries to fill the other details i want to tell him to select the date and close the calendar. How can it be acheived? Please help me out Quote Thanks & Regards, zy_abc
zy_abc Posted May 20, 2003 Author Posted May 20, 2003 Thanks PlausiblyDamp, i changed from part of form to a pop-up window and it is working fine. Quote Thanks & Regards, zy_abc
Administrators PlausiblyDamp Posted May 20, 2003 Administrators Posted May 20, 2003 Have you tried the DateTimePicker instead - may be an easier way of doing it. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
zy_abc Posted May 20, 2003 Author Posted May 20, 2003 But if we use DateTimePicker Time will get displayed. Further this calender is for Date of Birth. Is DateTimePicker suitable for this? Quote Thanks & Regards, zy_abc
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.