RadDateTimePicker Custom Format

8 posts, 1 answers
  1. Mark K.
    Mark K. avatar
    18 posts
    Member since:
    Oct 2008

    Posted 07 Oct 2009 Link to this post

    Is there any way to make the "AM" and "PM" in the RadDateTimePicker be lower case without changing the computer's DateTime format?

  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 13 Oct 2009 Link to this post

    Hi Mark K.,

    Thank you for the question.

    You can customize the data format through the CustomFormat property. You also have to set the Format property to custom. Please, consider the following code:
    this.radDateTimePicker1.Format = DateTimePickerFormat.Custom;
     
    void radDateTimePicker1_ValueChanged(object sender, EventArgs e)
    {
        if (this.radDateTimePicker1.Value.Hour > 11)
        {
            this.radDateTimePicker1.CustomFormat = "\"pm\" hh.mm";
        }
        else
        {
            this.radDateTimePicker1.CustomFormat = "\"am\" hh.mm";
        }
    }

    Do not hesitate to contact me again if you have other questions.

    Greetings,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mark K.
    Mark K. avatar
    18 posts
    Member since:
    Oct 2008

    Posted 27 Oct 2009 Link to this post

    The code you wrote puts the "am" and "pm" in front of the number, which I've never seen before.  Is that a European thing?  I fixed that, but the real problem is that when you edit the time in the box while the application is running there doesn't seem to be any way to edit the "am" and "pm" to change it to the other.

    If I click on the arrow key to increment the numbers, it never goes from am to pm.

    The whole edit routine of the time picker leaves much to be desired.  Why does it drop off leading zeros and go to single digits when you put your cursor on one of the numbers?

  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 28 Oct 2009 Link to this post

    Hello Mark K.,

    You should do the following to specify a time format which includes the "AM", "PM" time part:

    this.radDateTimePicker1.Format = DateTimePickerFormat.Custom;
                this.radDateTimePicker1.CustomFormat = "hh:mm:tt";

    I hope this helps.

    Regards,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Mark K.
    Mark K. avatar
    18 posts
    Member since:
    Oct 2008

    Posted 28 Oct 2009 Link to this post

    I already have that.  You didn't read the first post.  I was asking how to make the "am" and "pm" be lower case.
  7. Answer
    Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 29 Oct 2009 Link to this post

    Hello Mark K.,

    You do not have to change the date time format of your computer. You should just change a few settings of RadDateteTimePicker date time format.

    You can do the following:

    this.radDateTimePicker1.Culture = new CultureInfo("en-US");                  this.radDateTimePicker1.Culture.DateTimeFormat.AMDesignator = "am";
    this.radDateTimePicker1.Culture.DateTimeFormat.PMDesignator = "pm";

    You can use any string at the place of "AMDesignator" and "PMDesignator". If you have more questions, please contact us again.

    Regards,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Mark K.
    Mark K. avatar
    18 posts
    Member since:
    Oct 2008

    Posted 29 Oct 2009 Link to this post

    Thanks.  That's what I needed.
  9. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 30 Oct 2009 Link to this post

    Hi Mark K.,

    I am happy that this helps. I hope that everything is going well with your application. If you have additional questions, please do not hesitate to contact us.

    All the best,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for WinForms is Visual Studio 2017 Ready