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

Needs Smarter TimePicker

5 Answers 101 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
chintan
Top achievements
Rank 1
chintan asked on 30 Oct 2009, 05:53 AM
Hi,

We need to customize the way TimePicker is working.

If we enter "5" into a time field it assumes 5 a.m.. This needs to be smarter. When a user enters the following, default to:
a. 7-11 assumes AM
b. 12 assumes PM
c. 1-6 assumes PM
d. If the user types an 'a' or 'p' after a number it will set the time appropriately. For example 1a returns 1:00AM, 8p returns 8:00PM.

Please help me on this.
Thanks in advance.

5 Answers, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 02 Nov 2009, 10:52 AM
Hello chintan,

The requested features are possible only if you bind the RadTimePicker to some custom ViewModel and a custom IValueConverter. This converter will help you to defined the different TimeSpan format in the RadTimePicker's TextBox. Attached is a sample project showing the described technics. Let us know if something is still not clear for you. 

All the best,
Kaloyan
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.
0
chintan
Top achievements
Rank 1
answered on 03 Nov 2009, 06:18 PM
Hi Kaloyan,

Thank you very much for your reply. we will look in to the solution.

Thanks,
0
chintan
Top achievements
Rank 1
answered on 03 Nov 2009, 06:20 PM
Hi Kaloyan ,

Thank you very much for your reply with the solution.

But sorry to say you that this doesnt satisfy our requirement.

We need the format of 00:00 not 00:00:00

Even when we tried to put any number int he text box it didnt even fire any event of the IValueConverter interface implemented class.

Could you please give us a solution satisfying any of our need??

e.g. (a. 7-11 assumes AM)

Thanks,
0
Kaloyan
Telerik team
answered on 06 Nov 2009, 09:26 AM
Hi chintan,

To accomplish this task (00:00:00 to 00:00) you can add this code in the Convert method of the IValueConverter implementation class:

return DateTime.Parse(value.ToString()).ToShortTimeString();
 In case you want to manage the user input of the control, my advice is to use our RadMaskedTextBox control instead of the RadTimePicker. Check our new Q3 2009 release examples and see weather they will match your case.

Kind regards,
Kaloyan
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.
0
Gaurang
Top achievements
Rank 1
answered on 19 Jul 2011, 11:12 AM
Hi,

I have same requirement and everyting is working good using RadTimePicker control. But I when user enter 1 into Time Textbox that time it displaydate 1:00 AM. Insted of that I want 1:00 PM by default,

I want 1:00 PM when user enter 1 insted of 1:00 AM......upto........6 only

I try to do this but it is not working

 

void radTimePicker_ParseDateTimeValue(object sender, ParseDateTimeEventArgs args)

 

{

 

double Num;

 

 

string input = args.TextToParse.ToLower();

 

System.Globalization.

DateTimeFormatInfo formatInfo = new System.Globalization.DateTimeFormatInfo();

 

 

bool isNum = double.TryParse(input, out Num);

 

 

if (isNum)

 

{

 

if (Num >= 1 && Num <= 6)

 

{

radTimePicker.DisplayDate.Add(

new TimeSpan(12 + Convert.ToInt32(input)));

 

 

//radTimePicker.DisplayDate.AddHours(12 + Convert.ToInt32(input)));

 

 

//args.Result.Value.AddHours(12 + Convert.ToInt32(input));

 

}

}

}

Please reply me..........

Thanks,
Gaurang.

Tags
TimePicker
Asked by
chintan
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
chintan
Top achievements
Rank 1
Gaurang
Top achievements
Rank 1
Share this question
or