Display NullText for a Time Picker?

8 posts, 1 answers
  1. dave
    dave avatar
    10 posts
    Member since:
    Mar 2011

    Posted 06 May 2011 Link to this post

    I'm using a DateTimePicker for time entry by setting Format = Custom and CustomFormat = "h:mm tt"  (ex, 12:34 PM) This is working fine as long as I have a value assigned.

    Sometimes I don't have a value for this field and would like to display the NullText.  When working with dates, I call SetToNullValue() and the NullText is displayed.  However, with the way I've set up the picker for times, the NullText is not displayed and I'm left with an empty data entry text box.  This also happens when Format = Time, so I think the issue is related to not displaying the date, rather than what the time format is.

    Is there a way to use the CustomFormat mentioned above and also get the NullText to display after SetToNullValue() is called?  I don't care what the date value is and only need resolution of minutes, so tricks involving setting the date or time to special values are probably ok.

    Thanks,
    DaveL
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 11 May 2011 Link to this post

    Hello dave,

    I was not able to reproduce the described issue. Can you please post a code sample which reproduces the issue? This will help me investigate it in detail and provide you with adequate answers.

    I am looking forward to hearing from you.

    Best wishes,
    Ivan Todorov
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. dave
    dave avatar
    10 posts
    Member since:
    Mar 2011

    Posted 11 May 2011 Link to this post

    I created a VS 2010 project with the default form.  Below is the complete text of the form constructor.  The RadDateTimePicker code is what was generated when the control was added to a form.

    public Form1()
    {
        InitializeComponent();
     
        RadDateTimePicker dtmCompletedAt;
        dtmCompletedAt = new RadDateTimePicker();
        dtmCompletedAt.CustomFormat = "h:mm tt";
        dtmCompletedAt.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
        dtmCompletedAt.Location = new System.Drawing.Point(10, 10);
        dtmCompletedAt.MaxDate = new System.DateTime(2099, 12, 31, 0, 0, 0, 0);
        dtmCompletedAt.MinDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0);
        dtmCompletedAt.Name = "dtmCompletedAt";
        dtmCompletedAt.NullDate = new System.DateTime(2000, 1, 1, 0, 0, 0, 0);
        dtmCompletedAt.NullText = "Select...";
        dtmCompletedAt.ShowUpDown = true;
        dtmCompletedAt.Size = new System.Drawing.Size(150, 20);
        dtmCompletedAt.Value = new System.DateTime(2000, 1, 1, 0, 0, 0, 0);
        this.Controls.Add(dtmCompletedAt);
     
        dtmCompletedAt.SetToNullValue();
    }

    My expectation is that since the Value of the DateTimePicker is set to the NullDate value, and also SetToNullValue() has been called, the the DateTimePicker will display the NullText.  However, the DateTimePicker actually displays an empty text box. 

    While putting this sample together I discovered that the problem is actually related to setting ShowUpDown=true, which seems to be recommended for a TimePicker.  Setting it to false does cause the NullText to display; but it also shows the calendar drop down, which is not appropriate for a time picker.

    I guess the revised question should be:
    How do I get the NullText to appear for a TimePicker, and not also show the drop down calendar?  Having the spin buttons would be nice, but is not a requirement.

    Thanks,
    DaveL
  5. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 16 May 2011 Link to this post

    Hi dave,

    Thank you for contacting us.

    Indeed, the issue is present when the ShowUpDown property is set to true. I have added it to PITS so you can track its progress. Here you can find the PITS Issue: Public URL

    As a workaround, I would suggest using the date-time picker without setting the ShowUpDown property, but hiding the drop down button which shows the calendar. Here is how this could be done:

    dtmCompletedAt.DateTimePickerElement.Children[1].Children[1].Visibility = ElementVisibility.Collapsed;

    Your Telerik points have been updated for reporting this issue.

    In addition to this, I would like to mention that there are plans to improve RadDateTimePicker and other editors for the next release as you can see on the Q2'11 Roadmap.

    All the best,
    Ivan Todorov
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  6. dave
    dave avatar
    10 posts
    Member since:
    Mar 2011

    Posted 16 May 2011 Link to this post

    Thanks!  This is a fine solution for now.

    I didn't see any details for the Q2 update to the DateTimePicker, but I'd like to encourage providing a drop-down table of values to pick from, like the Silverlight/WPF TimePicker.

    DaveL
  7. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 19 May 2011 Link to this post

    Hello dave,

    Thank you for your feedback.

    Could you please elaborate a bit more and provide us with detailed description and/or images of the "drop-down table of values". Did you mean something like the control in the attached image?

    Thank you in advance for your time and cooperation.

    Best wishes,
    Stefan
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  8. dave
    dave avatar
    10 posts
    Member since:
    Mar 2011

    Posted 19 May 2011 Link to this post

    The image you provided is for a date picker.  That layout could work for time also, by having dropdowns for hour and minute rather than month/day/year.  However, what I was thinking of is what you currently do with your Silverlight/WPF Time Picker control.  See the example at http://www.telerik.com/products/silverlight/timepicker.aspx.

    Thanks,
    DaveL
  9. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 25 May 2011 Link to this post

    Hi dave,

    Thank you for these additional details.

    I have added this into our PITS system as a feature request. Once it gathers enough votes, we will consider its implementation. You can add your vote by following this link. Your Telerik points have been updated for this feature request.

    Should you have any other questions or suggestions do not hesitate to contact us.
     
    All the best,
    Stefan
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Back to Top
UI for WinForms is Visual Studio 2017 Ready