JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Handling Month Calendar Control Events

There are two main events in month calendar controls-DateChanged (the default event), which happens when the date in the control changes (either through user actions or in code); and DateSelected, which happens when the user selects a new date.

As discussed in the In Depth section of this chapter, you can select entire ranges of dates in month calendar controls. To handle such ranges, you can use the SelectionStart, SelectionEnd, SelectionRange.Start, and SelectionRange.End properties to get DateTime objects set to times that straddle the selected range. For example, here's how I indicate which day of the month the user has selected in the Pickers example:

Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles _
    TextBox1.Text = "Day of the month selected: " & _
End Sub

You can see the result in Figure 8.16, where I've selected a date; the corresponding day of the month is reported in the text box at the bottom of the form.

Figure 8.16: Handling month calendar control events.
Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor