Hi,
I have a requirement to display all the time slot descriptions in a 24 hour format. Eg. either "1:00 pm" or "13:00" would suffice. Is this possible?
If not directly, then I guess a creation filter is the way to go?
Thanks!
Ryan
The example I posted used a format of "HH"; it is possible you just have to change that to "HH:mm". It looks by the screen shot like you are using a TimeSlotInterval of 'TenMinutes', but I am at a loss as to how you got the text to appear for each slot (by default, it only appears for the first slot in the hour section). If you could illuminate on that point we can try to help.
Hi Brian
Thank you so much for the code example - i try not to ask for code (but when it comes to Creation & Draw Filters I am at a bit of a loss.
Close by no cigar!
The hours appear to be be formatted correctly but the minutes are not appearing.
Here is my code converted to VB.NET (the interesting part anyways)
Dim hourElement As nsDayView.HourUIElement = TryCast(parent, nsDayView.HourUIElement) If hourElement IsNot Nothing Then Dim descriptorElement As nsDayView.TimeSlotDescriptorUIElement = TryCast(hourElement.GetAncestor(GetType(nsDayView.TimeSlotDescriptorUIElement)), nsDayView.TimeSlotDescriptorUIElement) Dim slot As TimeSlot = descriptorElement.FirstTimeSlot hourElement.Text = slot.StartTime.ToString(Me.format) End If Dim timeSlotDescriptorElement As nsDayView.TimeSlotDescriptorUIElement = TryCast(parent, nsDayView.TimeSlotDescriptorUIElement) If timeSlotDescriptorElement IsNot Nothing Then Dim minuteElement As nsDayView.MinuteUIElement = TryCast(timeSlotDescriptorElement.GetDescendant(GetType(nsDayView.MinuteUIElement)), nsDayView.MinuteUIElement) If minuteElement IsNot Nothing Then minuteElement.Text = "00" End If End If
What am I doing wrong to end up with the following image: (NOTE even though 1pm is not shown in the image I can assure you that the control now shows "13" which is almost there but I want "13:00" -- "13:15" -- "13:30" -- "13:45" -- "14:00")
Thanks In Advance
using Infragistics.Win;using Infragistics.Win.UltraWinSchedule;using nsDayView = Infragistics.Win.UltraWinSchedule.DayView;
this.dayView.CreationFilter = new TimeSlotDecriptorCreationFilter( "HH" );
#region TimeSlotDecriptorCreationFilter/// <summary>/// Provides a way to add labels for DayView's TimeSlotUIElements/// </summary>public class TimeSlotDecriptorCreationFilter : IUIElementCreationFilter{ private string format = null; public TimeSlotDecriptorCreationFilter( string format ) { this.format = format; }
#region IUIElementCreationFilter interface implementation
void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { nsDayView.HourUIElement hourElement = parent as nsDayView.HourUIElement; if ( hourElement != null ) { nsDayView.TimeSlotDescriptorUIElement descriptorElement = hourElement.GetAncestor( typeof(nsDayView.TimeSlotDescriptorUIElement) ) as nsDayView.TimeSlotDescriptorUIElement;
TimeSlot slot = descriptorElement.FirstTimeSlot;
hourElement.Text = slot.StartTime.ToString(this.format); }
nsDayView.TimeSlotDescriptorUIElement timeSlotDescriptorElement = parent as nsDayView.TimeSlotDescriptorUIElement; if ( timeSlotDescriptorElement != null ) { nsDayView.MinuteUIElement minuteElement = timeSlotDescriptorElement.GetDescendant( typeof(nsDayView.MinuteUIElement) ) as nsDayView.MinuteUIElement;
if ( minuteElement != null ) minuteElement.Text = "00"; }
}
bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { return false; }
#endregion IUIElementCreationFilter interface implementation}#endregion TimeSlotDecriptorCreationFilter
Can you point me to an example of setting the TimeSlotDescriptor "time format" to 24 Hour time/Military Time
eg: 1:00 pm = 13:00
Cheers
Aaron
Note that it uses the time format specified by the current culture, so in cases where the current culture's time format uses "H" as opposed to "h", you get this automatically.
If you want to force this regardless of the current culture settings, yes, you could use a creation filter. You can get the associated TimeSlot by using HourUIElement.GetAncestor(typeof(TimeSlotDescriptorUIElement)) to get the TimeSlotDescriptorUIElement, then accessing its FirstTimeSlot property.