简体   繁体   English

更改“月”日历控件中“今天”按钮的默认值

[英]Change default value for “Today” button in Month Calendar Control

I am making a calendar with a daily message. 我正在制作带有每日消息的日历。 I want to program the "Today: 2014-03-29" button on the calender (when you click it, it goes to today's day) I need to be able to change the value of that button in code. 我想对日历上的“ Today:2014-03-29”按钮进行编程(单击时将显示为今天),我需要能够在代码中更改该按钮的值。 I would like to be able to change the year to 2013 instead of 2014. 我希望能够将年份更改为2013年而不是2014年。

So ex. Today:2014-04-06 but i want it to display 2013-04-06 and go to April, 6 2013 instead of 2014. The picture is the calendar for reference. 今天:2014-04-06,但我希望它显示2013-04-06并转到2013年4月6日而不是2014年。图片是日历,仅供参考。 Keep in mind it needs to change the year for everyday so today it would be 2013-03-26 the tomorrow it would be 2013-03-27. 请记住,它每天都需要更改年份,所以今天应该是2013-03-26,明天应该是2013-03-27。

在此处输入图片说明

There's a property on the control that lets you set the preferred date. 控件上有一个属性,可让您设置首选日期。

monthCalendar1.TodayDate = new DateTime(2013, 4, DateTime.Now.Day);

You may want to do some validation, for things like a leap year. 您可能需要对诸如a年之类的内容进行验证。 If it's Feb 29, 2016 and you try to set it to Feb 29, 2015, you'll get an ArgumentOutOfRangeException . 如果是2016年2月29日,而您尝试将其设置为2015年2月29日,则会收到ArgumentOutOfRangeException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM