Needs Smarter TimePicker

6 posts, 0 answers
  1. chintan
    chintan avatar
    35 posts
    Member since:
    Apr 2009

    Posted 30 Oct 2009 Link to this post

    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.

  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 02 Nov 2009 Link to this post

    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.
  3. DevCraft banner
  4. chintan
    chintan avatar
    35 posts
    Member since:
    Apr 2009

    Posted 03 Nov 2009 Link to this post

    Hi Kaloyan,

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

    Thanks,
  5. chintan
    chintan avatar
    35 posts
    Member since:
    Apr 2009

    Posted 03 Nov 2009 Link to this post

    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,
  6. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 06 Nov 2009 Link to this post

    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.
  7. Gaurang
    Gaurang avatar
    29 posts
    Member since:
    Dec 2010

    Posted 19 Jul 2011 Link to this post

    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.

Back to Top
DevCraft banner