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

DateTimePicker Questions

5 Answers 176 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
MikeB
Top achievements
Rank 1
MikeB asked on 19 May 2009, 06:03 PM
Can the TextBox of the DateTimePicker be set to read only so that the user cannot manually edit any of the date?  I tried using dtp.DateTimePickerElement.TextBoxElement.TextBoxItem.ReadOnly = true, but I was still able to edit the day. 

When a minDate value is set it appears to the user that they can edit the day and be able to be set the date to a date less than the min date.  Worse yet, say you have a minDate of 5/19/2008 and 5/20/2008 is selected.  If you edit the day to 31 and then edit it again to 15, it will stay at 31 (display = 5/15/2008, value = 5/31/2008).  Very confusing.

In the constructor, I set the MinDate, NullDate and value of the DateTimePicker = DateTime.Today.  If today is 5/19/2008, using the Picker I cannot select 5/19/2008.  I can only select 5/20/2008 and greater.

Are there properties that I need to set to avoid this situation?

Thanks,
Mike

5 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 22 May 2009, 10:58 AM
Hello MikeB,

Here is sample code which disables editing in RadDateTimePicker textbox:

    RadMaskTextBox maskBox = (this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl as RadMaskTextBox);
            maskBox.Enabled = false;

I hope this helps.

Best wishes,
Boyko Markov
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.
0
MikeB
Top achievements
Rank 1
answered on 22 May 2009, 04:10 PM
Thanks, that will help.  I would prefer ReadOnly over Enabled but this will work.  I will need to set the foreground color to match the other controls.

You did not address the MinDate question.  You cannot select the MinDate Date.  Is this normal behavior?

Thanks,
Mike
0
Boyko Markov
Telerik team
answered on 25 May 2009, 02:00 PM
Hi MikeB,

I wasn't able to reproduce the second issue. Could you please send me a very simple project which demonstrates the problem or just a code snippet with RadDateTimePicker settings?

I'm looking forward to your reply.

Regards,
Boyko Markov
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.
0
MikeB
Top achievements
Rank 1
answered on 01 Jun 2009, 03:00 PM
Hi,
Thanks for the reply.  Sorry for the delay in responding.  I was out last week.

In the constructor of the form that has the DateTimePicker:
dtpCallBackDate.MinDate = DateTime.Today.AddDays(-1);

Now run the appliction, click the DropDown for the DTP and click on the date that would be the MinDate value.  It may set the value (can't remember), but it does not display in the DTP display field.

Thanks,

Mike



0
Boyko Markov
Telerik team
answered on 04 Jun 2009, 11:37 AM
Hi MikeB,

Thank you for the feedback. The value is selected and it is not shown in the DTP field because when you set the MinDate property it is automatically synchronized with the NullDate property. Hance when you set the MinDate as value, you actually set the NullDate property. When the current value is equal to the NullDate value then the display field is empty by design. Please write me back again if you need more information.

All the best,
Boyko Markov
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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
MikeB
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
MikeB
Top achievements
Rank 1
Share this question
or