TimeSlotItem Structure
Namespace:
Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
TimeSlotItem
Description
The Microsoft.SharePoint.WebControls.TimeSlotItem structure provides a lightweight object implementation to represent an arbitrary slot of time for representation in a variety of data views.
The TimeSlotItem structure functions by taking three parameters in its constructor:
SPCalendarItemContainer.RowSpan – a 32 bit integer representing the span of the row
SPCalendarItemContainer.ColumnSpan – a 32 bit integer representing the span of the column
SPCalendarItemContainer.CalendarItem – a SPCalendarItemContainer object containing date data exposure and data binding
Within the class, there is overloading on comparison operators on the TimeSlotItem as a value types. This is important, as value types cannot be null.
The Usage Scenario
The primary usage of the TimeSlotItem structure is when a class inherits from the Microsoft.SharePoint.WebControls.SPCalendarBase base class (which in turn inherits from the System.Web.UI.WebControls.DataBoundControl), it provides a typed implementation to represent a time slot by consuming a SPCalendarItemContainer object. This object can then be used as a column item by other time based row objects, such as the DailyTimeSlotRow class.
In the below, I am firstly demonstrating how the constructor functions with the TimeSlotItem by creating a basic, empty object.
Secondly, I am creating a SPCalendarItemContainer object by using the Control.FindControl method by passing in the ID "Container". Following, a new TimeSlotItem object is created by passing in the column and row integer values, along with the previously hydrated SPCalendarItemContainer object.
The ArrayList columnItems contains the column names of the view this object is going to be associated with, which is following consumed into the DailyTimeSlotRow constructor. Lastly, the TimeSlotItem is added to the DailyTimeSlotRow.ColumnItems collection.
C# Code Example
TimeSlotItem basicItem = new TimeSlotItem(0, 0, null);
SPCalendarItemContainer calendarItem = (SPCalendarItemContainer) FindControl("Container");
TimeSlotItem item = new TimeSlotItem(1, 1, calendarItem);
ArrayList columnItems = new ArrayList{"test", "test"};
DailyTimeSlotRow row = new DailyTimeSlotRow(1, columnItems);
row.ColumnItems.Add(item);
Visual Basic .NET Code Example
Dim basicItem As TimeSlotItem = New TimeSlotItem(0,0,Nothing)
Dim calendarItem As SPCalendarItemContainer = CType(FindControl("Container"), SPCalendarItemContainer)
Dim item As TimeSlotItem = New TimeSlotItem(1,1,calendarItem)
ArrayList columnItems = New ArrayList
{
"test", "test"
}
Dim row As DailyTimeSlotRow = New DailyTimeSlotRow(1,columnItems)
row.ColumnItems.Add(item)
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
The Microsoft.SharePoint.WebControls.TimeSlotItem structure provides a lightweight object implementation to represent an arbitrary slot of time for representation in a variety of data views.
The TimeSlotItem structure functions by taking three parameters in its constructor:
SPCalendarItemContainer.RowSpan – a 32 bit integer representing the span of the row
SPCalendarItemContainer.ColumnSpan – a 32 bit integer representing the span of the column
SPCalendarItemContainer.CalendarItem – a SPCalendarItemContainer object containing date data exposure and data binding
Within the class, there is overloading on comparison operators on the TimeSlotItem as a value types. This is important, as value types cannot be null.
The Usage Scenario
The primary usage of the TimeSlotItem structure is when a class inherits from the Microsoft.SharePoint.WebControls.SPCalendarBase base class (which in turn inherits from the System.Web.UI.WebControls.DataBoundControl), it provides a typed implementation to represent a time slot by consuming a SPCalendarItemContainer object. This object can then be used as a column item by other time based row objects, such as the DailyTimeSlotRow class.
In the below, I am firstly demonstrating how the constructor functions with the TimeSlotItem by creating a basic, empty object.
Secondly, I am creating a SPCalendarItemContainer object by using the Control.FindControl method by passing in the ID "Container". Following, a new TimeSlotItem object is created by passing in the column and row integer values, along with the previously hydrated SPCalendarItemContainer object.
The ArrayList columnItems contains the column names of the view this object is going to be associated with, which is following consumed into the DailyTimeSlotRow constructor. Lastly, the TimeSlotItem is added to the DailyTimeSlotRow.ColumnItems collection.
C# Code Example
TimeSlotItem basicItem = new TimeSlotItem(0, 0, null);
SPCalendarItemContainer calendarItem = (SPCalendarItemContainer) FindControl("Container");
TimeSlotItem item = new TimeSlotItem(1, 1, calendarItem);
ArrayList columnItems = new ArrayList{"test", "test"};
DailyTimeSlotRow row = new DailyTimeSlotRow(1, columnItems);
row.ColumnItems.Add(item);
Visual Basic .NET Code Example
Dim basicItem As TimeSlotItem = New TimeSlotItem(0,0,Nothing)
Dim calendarItem As SPCalendarItemContainer = CType(FindControl("Container"), SPCalendarItemContainer)
Dim item As TimeSlotItem = New TimeSlotItem(1,1,calendarItem)
ArrayList columnItems = New ArrayList
{
"test", "test"
}
Dim row As DailyTimeSlotRow = New DailyTimeSlotRow(1,columnItems)
row.ColumnItems.Add(item)
Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com
- 6/3/2010
- Adam Buenz - MVP