MonthCalendar help

Yeung

Member
Joined
Jun 15, 2007
Messages
22
Programming Experience
Beginner
I need to show the selected date in a MonthCalendar on a textbox, not the current date.

for example in a MonthCalendar everytime i click a date its value will be displayed in a textbox and will be replaced with another value every time i click another.

can someone show me how? Thanks!
 
VB.NET:
Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) _
Handles MonthCalendar1.DateSelected
    TextBox1.Text = MonthCalendar1.SelectionStart
End Sub
 
There is also a DateChanged event you could try, it's the default event triggers for more reasons than the DateSelected event; by keyboard/code/month changes in addition to explicit mouse select.
 
There is also a DateChanged event you could try, it's the default event triggers for more reasons than the DateSelected event; by keyboard/code/month changes in addition to explicit mouse select.
Yeah, I tried your first code but it only displays the current date, but i was able to fix it so it displays any selected date with your latest reply.

Code:
Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) _
Handles MonthCalendar1.DateChanged
TextBox1.Text = MonthCalendar1.SelectionStart.Date.ToLongDateString
End Sub

Thanks a lot man.
 
Both these events trigger for Date selection, but they differ for what reasons the event occur. If you select date with mouse there is no difference.
 
Back
Top