Issues manually entering a date into DateTimePicker

11 posts, 0 answers
  1. Sean
    Sean avatar
    10 posts
    Member since:
    Aug 2012

    Posted 16 Nov 2008 Link to this post

    Just trying out the Telerik Controls for Win Forms to see if it is worth switching to them from the ones I currently use. However I had a couple of problems when trying to manually enter dates on the DateTimePicker.  I found that if the date has been set to the null date by hitting the DEL key, then you tab off the control, then you cannot type in a date when you tab back to that control.  Also the DateTimePicker does not recognise partially entered years i.e. 1/1/08 for 01/01/2008.

    Is there a way to get around these issues?
    Thanks
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 20 Nov 2008 Link to this post

    Hello Sean,

    Thank you for writing.

    I managed to reproduce the described behavior and I agree that this should be changed. Unfortunately, I cannot give you any suitable work-around currently. Please, excuse us for the inconvenience. I have updated your Telerik points for bringing our attention to this. We will try to fix it as soon as possible.
     
    If you have other questions, do not hesitate to contact me again.

    Sincerely yours,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Fabien
    Fabien avatar
    43 posts
    Member since:
    Sep 2008

    Posted 21 Nov 2008 Link to this post

    Hi,

    I found a solution for this little issue.

    The problem is that you can't set to nullValue because in source code of RadDateTimePickerElement there is a "BypassUpdateOnLostFocus" set to true. (I think)
    But anyway, you cannot set the minvalue yourself, because Text won't be refresh. And if you refresh the Text yourself (RadDateTimePicker.DateTimePickerElement.TextBoxElement.TextBoxItem.Text), you'll have bad reactions (because of mask and RadMaskTextBox hosted in)

    My solution is to do this :

    Add an event for each RadDateTimePicker (same event for all in your form)

    private void RadDateTimePicker_Leave(object sender, EventArgs e)  
    {  
     RadDateTimePicker element = (RadDateTimePicker)sender;  
     if (String.IsNullOrEmpty(element.DateTimePickerElement.TextBoxElement.TextBoxItem.Text))  
      element.Value = element.NullDate.AddSeconds(1);  


    so, if control lost focus, you'll set to default value as well.

    Best regards,

    Fabien

     

     

  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 25 Nov 2008 Link to this post

    Hello Fabien,

    Thank you for sharing your code with us.

    Unfortunately, it does not bring the exact behavior, because it sets a min value. It is not suitable if you need a null value in your RadDateTimePicker. Nevertheless, your code could surely be useful to other Telerik customers and I have updated your Telerik points for your inquiry. I have also added this issue in our bug tracking system and it will be addressed in a future release.

    If you have other questions, do not hesitate to contact me again.

    Regards,
    Martin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Bill
    Bill avatar
    27 posts
    Member since:
    Oct 2008

    Posted 05 Mar 2009 Link to this post

    Here's a workaround I use.  If you....
        1) Set the NullDate property to blank at design time
        2) Set the Value property blank at design time
    ...then the following code works for us.  In this scenario the DateTimePicker control always stays null unless someone keys something into it:

        public partial class Form1 : Form  
        {  
            DateTime SampleDate = new DateTime(1900, 1, 1, 0, 0, 0);  
            public Form1()  
            {  
                InitializeComponent();  
     
                dtDate.Enter += new EventHandler(dtDate_Enter);  
                dtDate.Leave += new EventHandler(dtDate_Leave);  
                dtDate.SetToNullValue();  
            }  
     
            void dtDate_Enter(object sender, EventArgs e)  
            {  
                if (dtDate.Value == dtDate.NullDate || dtDate.Value == null)  
                {  
                    dtDate.Value = SampleDate;  
                }  
            }  
     
            void dtDate_Leave(object sender, EventArgs e)  
            {  
                if (dtDate.Value == SampleDate)  
                {  
                    dtDate.Value = dtDate.NullDate;  
                }  
            }  
        } 

     

    So if the user tabs into the control they can start typing immediately over a new sample date that is provided.  If they press tab again without typing anything the field will be set to blank again. You must use a sample date that is not valid because it gets erased when the user leaves the control. This seems a bit cheesy so if someone has a better workaround I'd be interested...

  7. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 07 Mar 2009 Link to this post

    Hello Bill,

    Thank you for sharing your code with us.

    I am glad that you have found work-around of this issue. I am sure that there are other users, that will find your code as useful too. We have plans to fix the issue, but our schedule is very tough and I cannot give a time frame at the moment.

    Do not hesitate to contact us again, if you have any other questions. 

    Best wishes,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Daniel
    Daniel avatar
    15 posts
    Member since:
    Jun 2009

    Posted 08 Oct 2009 Link to this post

    Hi,
    my DateTimePicker may not have a null Value, but i need a manually free enter date lika MS Access Control.

    I meen, the DateTimePicker gets the Focus and clear the Datestring, now i can enter my new Date like 1.1.2000

    How can i release this?
  9. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 12 Oct 2009 Link to this post

    Hi Daniel,

    Thank you for your question.

    RadDateTimePicker does not support this kind of editing. In your case, you can find RadMaskedEditBox as more suitable control. Write me back if you have other questions.

    Greetings,
    Martin Vasilev
    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.
  10. Darko
    Darko avatar
    14 posts
    Member since:
    Sep 2008

    Posted 27 Oct 2009 Link to this post

    Hi BIll,

    thanks for sharing your code. It worked well for me.
    However, I still have problems applying this to a DateTime RadGridView Column.
    Any ideas from the Telerik team for a possible workaround for the described problem?
    Basically, I would like to be able to manually enter a value in a ActiveEditor of the RadGridView.

    Thanks for your help,
    Darko Konrad
  11. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 30 Oct 2009 Link to this post

    Hi Darko,

    Thank you for writing. This approach cannot be used directly for GridViewDateTimeColumn, because the value of RadGridView editor depends on the cell value. Actually, if the cell value is null, RadGridDateTimeEditor has similar behavior. It shows the default date (today) and if the end user do not choose a date and leave the cell, than the null value for that cell remains.

    Greetings,
    Martin Vasilev
    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.
  12. Ruth Goldberg
    Ruth Goldberg avatar
    54 posts
    Member since:
    Dec 2009

    Posted 03 May 2010 Link to this post

    I found Bill's workaround very useful. But I also wanted the calendar to show today's date, so I set my NullDate to Now on form load and my SampleDate to 1 second later. This way, the user can also choose today's date from the calendar because the time will be different from the NullDate.
Back to Top
UI for WinForms is Visual Studio 2017 Ready