Microsoft.SharePoint.WebCon ...


ISPCalendarItem Interface (Microsoft.SharePoint.WebControls)

Namespace: Microsoft.SharePoint.WebControls
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Syntax

Visual Basic (Declaration)
Public Interface ISPCalendarItem
    Inherits IComparable
Visual Basic (Usage)
Dim instance As ISPCalendarItem
C#
public interface ISPCalendarItem : IComparable
See Also

Tags :


Community Content

Adam Buenz - MVP
ISPCalendarItem

Description

The Microsoft.SharePoint.WebControls.ISPCalendarItem interface inherits from the System.IComparable in order to instigate type-specific comparison methods (the IComparable interface contains the single method CompareTo for generic objects). The most useful scenario for the use of ISPCalendarItem is when working with the Microsoft.SharePoint.WebControls.SPCalendarItemContainer objects for casting support against the SPCalendarItemContainer.DataItem property.

The ISPCalendarItem interfaces functions by exposing common properties associated with an item in a Calendar:

BackgroundColorClassName – string representing the CSS class for the background of the item
CalendarType – integer representing the type of Calendar
Description - string representing the description of an item
Direction – string representing the direction of the item
DisplayFormUrl – string representing the Display FORMTYPE Url of the corresponding SPListItem
EndDate – DateTime representing the item end date
hasEndDate - Boolean representing whether the item has a specified ending
IsAllDayEvent - Boolean representing whether the item is an all day event
IsRecurrence - Boolean representing whether the item is a recurring event
IsRecurrenceException - Boolean representing whether an exception has occurred with the recurrence
ItemID – integer representing the ID of the corresponding SPListItem object
Location – string representing the location of the item
StartDate – DateTime representing when the item starts
Title – string representing the friendly title of the item
WorkSpaceLink – string representing the Url to the bound workspace to the item, if one exists

Usage Scenario

The primary usage of ISPCalendarItem is when working with the SPCalendarItemContainer class. Such an operation can be found within the shipped software, however is very useful when focusing a strongly typed approach within custom development projects reusing pre-existing SharePoint classes.

In the below, the MyClass class is inheriting from the System.Web.UI.WebControls.WebParts.WebPart class and the CreateChildControls is being overridden. Following, a recursion through the current control collection is being executed, testing if the type of the recurred control is SPCalendarItemContainer. If the type is SPCalendarItemContainer, then the Control object is being casted to a new SPCalendarItemContainer object. Following, a new ISPCalendarItem is created through casting against the newly created SPCalendarItemContainer object DataItem property.

C# Code Example

  public class MyClass : WebPart
{
protected override void CreateChildControls()
{
foreach (Control control in Controls)
{
if (control is SPCalendarItemContainer)
{
SPCalendarItemContainer calendarItem = (SPCalendarItemContainer) control;
ISPCalendarItem dataItem = (ISPCalendarItem) calendarItem.DataItem;
}
}
}
}

VB.NET Code Example

Public Class [MyClass]
Inherits WebPart
Protected Overloads Overrides Sub CreateChildControls()
For Each control As Control In Controls
If TypeOf control Is SPCalendarItemContainer Then
Dim calendarItem As SPCalendarItemContainer = DirectCast(control, SPCalendarItemContainer)
Dim dataItem As ISPCalendarItem = DirectCast(calendarItem.DataItem, ISPCalendarItem)
End If
Next
End Sub
End Class
Tags :

Page view tracker