I don't understand how the DatePicker works

3 posts, 1 answers
  1. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 20 Jan 2011 Link to this post

    I'm a neophyte Telerik RadControls user, having only recently gotten a subscription.  One of the primary reasons why we got these controls is because of our need for a date picker control on our WPF apps.  I wrote my own date picker control, which is OK, but it lacks a lot to be desired.  I believe that Telerik's controls will address my control's shortcomings.

    Now to explain what it is that I'm trying to accomplish.  My new WPF app is a replacement for an older VB6 app, that is used by our front desk personnel.  They need to enter a lot of data, some of it of type date.  They really hate having to type the "/", for example, when enter dates.  For example, when entering today's date, they're used to typing it into the old VB6 app and my new WPF app (with my custom date picker control) like this: "01202011"  However, when type it in, I've got a mask in place which already has the "/" in there, so it will look like this: "01/20/2011".

    So, I wanted to test out Telerik's RadDatePicker control and see how it works.  I quickly got up VS 2010 and created a new WPF app, and placed a RadDatePicker control there with a TextBox after it, so that I could tab off of the date picker control and see what happens. Telerik's RadDatePicker control displays the date it thinks your entering in a tooltip (I guess, nice feature, BTW), and I can see it's not getting the date correct.  For example, when I start entering numbers and the control tells me what it thinks I'm enter in the tooltip, this is what I get (what I enter is on the left, what it think the date is, is on the right):
    • 0 - 1/20/2000
    • 01 - 1/1/2011
    • 012 - 1/12/2011
    • 0120 - 1/20/0120
    • 01202 - 1/20/1202
    • 012020 - Error

    I don't get why it's defining the date to be the way it does, and certainly my users won't like it at all.  My guess is that I've got to configure something else to make it work the way my users want it to, only thing is I don't know how.  What am I doing wrong, or leaving out?

  2. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 25 Jan 2011 Link to this post

    Hi Rod,

    This is the default implementation of the control. You can write your own parsing logic If you are not good with the current one. The only think you have to do is to implement the ParseDateTimeValue event.

    private void RadDateTimePicker_ParseDateTimeValue(object sender, ParseDateTimeEventArgs args)
            {
                var currentTypedString = args.TextToParse;
                // put your value here as a result of your parsing logic.
                args.Result = somecustomvalue;
            }


    Best wishes,
    Kaloyan
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rod
    Rod avatar
    71 posts
    Member since:
    Jan 2011

    Posted 25 Jan 2011 Link to this post

    Thank you, Kaloyan.
Back to Top