Month Picker

2 posts, 1 answers
  1. David
    David  avatar
    66 posts
    Member since:
    Aug 2010

    Posted 08 Feb 2012 Link to this post

    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
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Feb 2012 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top