Typically, the beginning of the day coincides with midnight (hour zero, minute zero). For some applications it can be useful to consider the beginning of the day to be at some other time; the LogicalDayOffset property makes this possible.
The value of the property is added (to the DateTime struct to which it is applied) via the DateTime struct's Add method.
The absolute value of the property setting must be no larger than 23 hours and 59 minutes, so that the offset is less than one full day. Setting the property to a value outside this range results in an exception being thrown. Because the level of granularity with respect to time for the UltraCalendarInfo component is restricted to one minute, setting the property to a value that includes a seconds component will result in the seconds component being removed; for example, if the property is set to a value of 14 minutes and 59 seconds, the next time the property is accessed, it will return a value of 14 minutes, 0 seconds.
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim now As DateTime = DateTime.Now ' Create a TimeSpan that contains the same number of hours ' as the offset of the current time from midnight. Dim offset As TimeSpan = TimeSpan.FromHours(now.Hour) ' Create a TimeSpan that contains the number of hours remaining ' in the current day, including the current hour. Dim duration As TimeSpan = TimeSpan.FromHours((24 - now.Hour)) ' Assign the offset to the UltraCalendarInfo's LogicalDayOffset ' property, so that the logical day begins on the current hour. Me.ultraCalendarInfo1.LogicalDayOffset = offset ' Assign the duration to the UltraCalendarInfo's LogicalDayDuration property, ' so that the logical day ends at midnight of the following day. Me.ultraCalendarInfo1.LogicalDayDuration = duration End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; private void button1_Click(object sender, System.EventArgs e) { DateTime now = DateTime.Now; // Create a TimeSpan that contains the same number of hours // as the offset of the current time from midnight. TimeSpan offset = TimeSpan.FromHours( (double)now.Hour ); // Create a TimeSpan that contains the number of hours remaining // in the current day, including the current hour. TimeSpan duration = TimeSpan.FromHours( (double)(24 - now.Hour) ); // Assign the offset to the UltraCalendarInfo's LogicalDayOffset // property, so that the logical day begins on the current hour. this.ultraCalendarInfo1.LogicalDayOffset = offset; // Assign the duration to the UltraCalendarInfo's LogicalDayDuration property, // so that the logical day ends at midnight of the following day. this.ultraCalendarInfo1.LogicalDayDuration = duration; }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2