C#中有一个MonthCalender
有2个按钮可供选择月份
1月,2月等等..
无论如何,我可以检测到用户改变了月份?
答案 0 :(得分:3)
试试这个
private int MonthValue = 0;
private bool bChanged = false;
private void Form1_Load(object sender, EventArgs e)
{
MonthValue = monthCalendar1.TodayDate.Month;
}
private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
if (MonthValue != monthCalendar1.SelectionStart.Month)
{
//changed
bChanged = true;
MonthValue = monthCalendar1.SelectionStart.Month;
}
else
{
//not changed
bChanged = false;
}
}
答案 1 :(得分:0)
在日历控件上使用OnVisibleMonthChanged
并创建如下事件:
protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
// Further processing goes here
}