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

DateTimePicker to accept character as input

3 Answers 66 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Antony
Top achievements
Rank 1
Antony asked on 14 Sep 2011, 03:24 PM
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

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 15 Sep 2011, 12:37 PM
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 >>

0
Antony
Top achievements
Rank 1
answered on 15 Sep 2011, 03:22 PM
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
0
Yana
Telerik team
answered on 21 Sep 2011, 12:18 PM
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 >>

Tags
DateTimePicker
Asked by
Antony
Top achievements
Rank 1
Answers by
Yana
Telerik team
Antony
Top achievements
Rank 1
Share this question
or