This post is choosing date.
There are two date control.
MonthCalendar and DateTimePicker.
MonthCalendar is Monthly Calendar.
DateTimePicker is date picker.
I added datetimepicker and monthcalendar.
If you click to datetimepick you can see display just one day.
But, MonthCalendar is display max 1 week.
You can see above picture choose day 13~ day 19.
If you want one day, you choose one day.
This is code for monthcalendar.
1 2 3 4 5 6 7 8 | private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) { if (monthCalendar1.SelectionRange.Start == monthCalendar1.SelectionRange.End) textBox1.Text = monthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd"); else textBox1.Text = monthCalendar1.SelectionRange.Start.ToString("yyyy-MM-dd") + "~" + monthCalendar1.SelectionRange.End.ToString("yyyy-MM-dd"); } |
MonthCalendar use method 'SelectionRange.Start' and 'SelectionRange.End'.
This is DateTimePicker.
You will click icon, DateTimePicker show pull down calendar.
Your choose date display to left text box.
1 2 3 4 | private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { textBox1.Text = dateTimePicker1.Value.ToString("yyyy-MM-dd"); } |
datetime picker use method 'value'.
No comments:
Post a Comment