This is a migrated thread and some comments may be shown as answers.

Month Picker

1 Answer 388 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 2
David asked on 08 Feb 2012, 11:08 PM
Hi,

is it possible to change the date/time picker into a year/month picker? I noticed you can do this very easily with the WPF DateTimePicker but cannot see a way to do this on the winforms

thanks

David

1 Answer, 1 is accepted

Sort by
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 09 Feb 2012, 10:58 AM
Hi David,

If I understand your requirement correctly, then you can change the RadDateTimePicker to show month and year in the following way:

1: Create a form with a RadDateTimePicker and a RadButton
2: Hook up the events for the RadButton click event and form load event.
3: Add the following code

private void RadForm1_Load(object sender, EventArgs e)
{
    this.radDateTimePicker1.CustomFormat = "MM:yyyy";
    this.radDateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    this.radDateTimePicker1.ShowUpDown = true;
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    RadMessageBox.Show("Month Picked: " + this.radDateTimePicker1.Value.Month.ToString() + " Year Picked: " + this.radDateTimePicker1.Value.Year.ToString());
}

Hope this helps. If this is what you need, please remember to mark as answer. If you need further help, just let me know
Thanks
Richard
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
David
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
Share this question
or