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

Timepicker - Click -> 15 min

1 Answer 64 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Shaggy
Top achievements
Rank 1
Shaggy asked on 02 Dec 2013, 09:34 PM
Hello,

i need a solution, that the user only can make time inputs in 15 minute steps. For example:

08:00
08:15
08:30
....

Is there a opportuniy, special for the arrow keys, when he clicks on it and the minutes are chosen, that the tick is 15 minutes and not 1 minute?

Greets,
Shaggy

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Dec 2013, 04:03 PM
Hello Zeljko,

Thank you for contacting Telerik Support.

You can restrict the user to make time inputs in 15 minute steps as follows:
public Form1()
{
    InitializeComponent();
 
    radTimePicker1.Step = 15;
    radTimePicker1.Value = new DateTime(1,1,1,radTimePicker1.Value.Value.Hour, 0 ,0);
    ((MaskDateTimeProvider)radTimePicker1.TimePickerElement.MaskedEditBox.Provider).MinutesStep = 15;
    radTimePicker1.TimePickerElement.MaskedEditBox.KeyPress += MaskedEditBox_KeyPress;
}
 
void MaskedEditBox_KeyPress(object sender, KeyPressEventArgs e)
{
    if (((MaskDateTimeProvider)radTimePicker1.TimePickerElement.MaskedEditBox.Provider).SelectedItemIndex == 2)
        e.Handled = char.IsLetterOrDigit(e.KeyChar);
}

The user is allowed to use the arrow keys for minutes navigation in 15 minutes interval. But the functionality to type in directly the minutes numbers is disabled due to the complexity of handling specific cases.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Shaggy
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or