Version

SetDuration(TimeSpan,TimeSpanFormat) Method

Sets the value of the Duration property.
Syntax
'Declaration
 
Public Sub SetDuration( _
   ByVal value As TimeSpan, _
   ByVal format As Infragistics.Win.TimeSpanFormat _
) 
public void SetDuration( 
   TimeSpan value,
   Infragistics.Win.TimeSpanFormat format
)

Parameters

value
A TimeSpan structure containing the new value for the Duration property.
format
A TimeSpanFormat constant which describes the unit of time representation.
Remarks

By using the SetDuration method as opposed to the Duration property, the developer can specify the unit of time representation for the task. For example, if the method is called with a TimeSpan of one day, and 'Hours' as the value of the format parameter, the value is displayed in the task grid as "24 hrs", and spans three actual days (assuming that the workday length is defined as eight hours in duration). With the same TimeSpan value of one day and a value of 'Days' for the format parameter, however, the assigned value is "converted" to working hours based on the value of the TaskDurationWorkingTimePerDay property. If TaskDurationWorkingTimePerDay is set to a TimeSpan of eight hours, this would result in an assignment of one day being "converted" to eight working hours, and the task spans one full working day, or eight hours. The duration field of the task grid, in this example, would display "1 day", but the effective duration of the task resolves to the number of working hours in one day.

In addition to the conversion performed for a format value of 'Days' as discussed in the previous paragraph, an additional conversion is performed for a value of 'Weeks'. When the 'Weeks' constant is specified, the units are converted to days using the number of working days in a week as the basis for conversion. By default, UltraCalendarInfo defines the number of days on a work week as five (Saturday and Sunday are non-workdays). Using this definition, if a TimeSpan of five days is assigned, using the 'Weeks' format, this method will "convert" the value as it does for the 'Days' format, but the duration field in the task grid will display the value as "1 wk", even though the actual underlying assignment was for five days.

When a format of 'Hours' or 'Minutes' is used, no conversion is performed, and the assigned value is interpreted as being expressed in working hours. Assigning a TimeSpan of 6 hours, for example, will cause the task to span across 6 hours of working time; a value of 32 hours would span across 4 working days (assuming again that the workday length is defined as eight hours in duration).

Calling the SetDuration method produces the same effect as changing the value of the duration field in the task grid.

Requirements

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

See Also