This is a migrated thread and some comments may be shown as answers.
Custom Hours in the Time Picker
5 Answers 49 Views
This is a migrated thread and some comments may be shown as answers.
Denis Cilliers
Top achievements
Rank 1
Denis Cilliers asked on 18 Feb 2013, 09:50 AM
Is there a way to limit the hours displayed in the Time Picker as some times would not be allowed in the logic of the application but are displayed in the picker, such as 00:00 01:00 etc

Can I remove these hours and have a range from say 07:00 to 21:00

Thanks

Denis

5 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 21 Feb 2013, 07:29 AM
Hi Denis,

Thank you for writing.

These hours cannot be removed from the table and I suggest to make them Disabled. To do this you can handle the TimeCellFormatting event and set Enabled to false if the time for this element is out of range. Please, refer to the code below:
this.radTimePicker1.TimeCellFormatting += new Telerik.WinControls.UI.TimeCellFormattingEventHandler(radTimePicker1_TimeCellFormatting);
 
 
void radTimePicker1_TimeCellFormatting(object sender, Telerik.WinControls.UI.TimeCellFormattingEventArgs e)
{
    minTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 0, 0);
    maxTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0);
    e.Element.Enabled = e.Element.Time >= minTime && e.Element.Time < maxTime;
}

I suggest to display Hours & Minutes in one table instead of two tables:
this.radTimePicker1.TimeTables = Telerik.WinControls.UI.TimeTables.HoursAndMinutesInOneTable;

Please, refer to the attached project.

I hope this helps.

All the best,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Denis Cilliers
Top achievements
Rank 1
answered on 21 Feb 2013, 03:03 PM
Cool thank you it works nicely 
For the Code Converter it seems to have an issue with Events, and again this answer like so many has an event handler.
It does not add these parts very well 
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
 
AddHandler Me.RadTimePicker1.TimeCellFormatting, AddressOf radTimePicker1_TimeCellFormatting

Thanks  it is now working 
0
Peter
Telerik team
answered on 26 Feb 2013, 09:39 AM
Hi Denis,

We are aware of this limitation of the converter, please excuse us for the introduced inconvenience.

The posts in the forum do not provide information about the programming language and unless you mention it we provide C# code.

I hope that you find this information useful.

Regards,
Peter
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Denis Cilliers
Top achievements
Rank 1
answered on 27 Feb 2013, 09:16 AM
Hi Peter 

You are very kind to offer to translate the C# to VB or even provide it in VB, The tool that Telerik provides is very good actually.

It is just that this project atm is in VB, i'm sure my next will be in C# again, so don't worry about it keep providing it in C# as i'm sure that is what you are working on all the time.

It also keeps us VB (current project) on our toes as we have to keep translating between the two languages and it makes us think about the code a bit more than I would if I just had to copy and paste.

Thanks again for the hard work

Denis
0
Peter
Telerik team
answered on 28 Feb 2013, 03:15 PM

You are welcome Denis. Let us know if you need anything else.

Regards,
Peter
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

Interested, but can’t attend? Register anyway and we’ll send you the recording.
Asked by
Denis Cilliers
Top achievements
Rank 1
Answers by
Peter
Telerik team
Denis Cilliers
Top achievements
Rank 1
Share this question
or