Hi Judy,
Indeed, when RadDateTimePicker
Value is set to
NullDate, you cannot type in the editing textbox portion. However, it is not necessary to open the calendar drop down to start typing again. Instead, when Entering the RadDateTimePicker, you can set a date different from the
NullDate. This will display a date in the text box portion and you will be able to edit it.
As to your second question, the value of RadDateTimePicker is updated automatically when you stop writing in it. So, if you set a correct date and Leave the RadDateTimePicker after that, this date should stay. However, if you edit the year and type something like "200" and wait for about 500 miliseconds (0.5 second), the value will be updated the the
MinDate value, because "200" is out of the date range, specified by
MinDate and
MaxDate properties.
In order to set a bigger time interval in which to set the correct date, please consider using the following workaround:
- Put the following code snippet in the Form() contructor after the InitializeComponent() method:
Type t = this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl.GetType();FieldInfo info = t.GetField("editingTimer", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); |
Timer timer = new Timer(); |
timer.Interval = 2000; |
info.SetValue(this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl, timer); |
timer.Tick += new EventHandler(timer_Tick); |
|
- Now let me explain what happens. I get the Timer instance, which updates the Date on its Tick method call. Then I change this instance with a new instance and set its interval to 2000 miliseconds which is equal to 2 seconds. Lastly I subscribe to the Tick event of the new Timer instance where I do the following:
void timer_Tick(object sender, EventArgs e) |
{ |
Type t = this.radDateTimePicker2.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl.GetType(); |
MethodInfo info = t.GetMethod("editingTimer_Tick", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); |
try |
{ |
info.Invoke(this.radDateTimePicker2.DateTimePickerElement.TextBoxElement.TextBoxItem.HostedControl, |
new object[] { sender, e }); |
} |
catch (Exception ex) |
{ |
// Show the exception message |
// MessageBox.Show(ex.ToString()); |
} |
} |
|
Here I call our old timer's tick event handler as it won't be called for the new timer - this keeps the internal logic alive, but we have a new timer object which we use now.
I have demonstrated the approaches in the sample project attached.
If you have additional questions, feel free to contact me.
Best wishes,
Nikolay
the Telerik team
Check out
Telerik Trainer, the state of the art learning tool for Telerik products.