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

Display NullText for a Time Picker?

7 Answers 121 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
dave
Top achievements
Rank 1
dave asked on 06 May 2011, 10:21 PM
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

7 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 11 May 2011, 03:31 PM
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.
0
dave
Top achievements
Rank 1
answered on 11 May 2011, 04:43 PM
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
0
Accepted
Ivan Todorov
Telerik team
answered on 16 May 2011, 05:21 PM
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.
0
dave
Top achievements
Rank 1
answered on 17 May 2011, 12:28 AM
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
0
Stefan
Telerik team
answered on 19 May 2011, 04:28 PM
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.
0
dave
Top achievements
Rank 1
answered on 19 May 2011, 11:28 PM
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
0
Stefan
Telerik team
answered on 25 May 2011, 05:54 AM
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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
dave
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
dave
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or