DateTimePicker,MonthCalendar控件的使用

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DateTimePicker_MonthCalendar控件的使用
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            this.monthCalendar1.SelectionStart = this.dateTimePicker1.Value;
            this.monthCalendar1.SelectionEnd = this.dateTimePicker1.Value.AddDays(6);
        }

        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            this.textBox1.Text = "其实日期:" + e.Start.ToLongDateString() + ";终止日期:" + e.End.ToLongDateString();
        }
    }
}

你可能感兴趣的:(Visual,C#)