private void OnTodayClick(object sender, EventArgs e)
{
// Remove any time information as selecting a date is based only on the day
DateTime today = _calendar.TodayDate;
// Can only set a date that is within the valid min/max range
if ((today >= _calendar.MinDate) && (today <= _calendar.MaxDate))
{
_calendar.SetSelectionRange(today, today);
_needPaintDelegate(this, new NeedLayoutEventArgs(true));
}
// Is the menu capable of being closed?
if (CloseOnTodayClick && (Provider != null) && Provider.ProviderCanCloseMenu)
{
// Ask the original context menu definition, if we can close
CancelEventArgs cea = new CancelEventArgs();
Provider.OnClosing(cea);
if (!cea.Cancel)
{
// Close the menu from display and pass in the item clicked as the reason
Provider.OnClose(new CloseReasonEventArgs(ToolStripDropDownCloseReason.ItemClicked));
}
}
}