- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- GcDate gcDate1 = new GcDate();
- this.Controls.Add(gcDate1);
- gcDate1.DropDownCalendar.CalendarDimensions = new Size(3, 1);
- gcDate1.DropDownOpening += gcDate1_DropDownOpening;
- }
- void gcDate1_DropDownOpening(object sender, DropDownOpeningEventArgs e)
- {
- GcDate gcDate1 = sender as GcDate;
- if (gcDate1 == null)
- {
- return;
- }
- DateTime currentValue = gcDate1.Value.HasValue ? gcDate1.Value.Value : DateTime.Today;
- DateTime lastMonthValue = currentValue.AddMonths(-1);
- gcDate1.DropDownCalendar.FocusDate = lastMonthValue;
- }
- }
复制代码
示例代码如上。看看是不是你想要的效果。 |