DateTimePicker to accept character as input

4 posts, 0 answers
  1. Antony
    Antony avatar
    3 posts
    Member since:
    Jun 2011

    Posted 14 Sep 2011 Link to this post

    Hi Guys,
                Can I customize a DateTimePicker to accept character and convert it into that particular date..

    For example..
           If I enter T ---->it should convert to Todays date and present time.
           If I enter T-10 ---->it should convert to Todays date minus 10 days and display the date and present time

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 15 Sep 2011 Link to this post

    Hi Antony,

    You can implement your own parsing logic in ParseDateTimeValue event, please check here for more details.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Antony
    Antony avatar
    3 posts
    Member since:
    Jun 2011

    Posted 15 Sep 2011 Link to this post

    Hi Yana,

    Thanks for your Reply, I appreciate it. If you don't mind can I have a simple example to illustrate it.








    Regards,
    Antony Nadan A.F
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Sep 2011 Link to this post

    Hello Antony,

    You can check this article for a simple example about custom parsing.   The event handler in your case should be similar to the following code snippet:

    private void RadDateTimePicker_ParseDateTimeValue(object sender, Telerik.Windows.Controls.ParseDateTimeEventArgs args)
    {
        string input = args.TextToParse.ToLower();
        if (input == "t")
        {
            args.Result = DateTime.Now;
            args.IsParsingSuccessful = true;
        }
    }

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top