共用方式為


SPListItemVersionCollection class

表示SPListItemVersion物件的集合。

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.SPBaseCollection
      Microsoft.SharePoint.SPListItemVersionCollection

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public NotInheritable Class SPListItemVersionCollection _
    Inherits SPBaseCollection
'用途
Dim instance As SPListItemVersionCollection
public sealed class SPListItemVersionCollection : SPBaseCollection

備註

使用SPListItem類別的Versions屬性,傳回集合的清單項目的版本。

使用索引子來從集合傳回單一版本。例如,如果集合指派給一個名為collListItemVersions變數中,使用在 C# 的collListItemVersions[index]或collListItemVersions(index)index所在集合中的版本編號的 Visual Basic 中。index,較低的值較新版本。

Examples

下列程式碼範例逐一查看清單中的項目,並還原先前的版本的項目,如果目前的版本中的欄位等於指定的值。

Dim list As SPList = New SPSite("http://MySiteCollection").AllWebs("MyWebSite").GetList("http://MySiteCollection/MyWebSite/Lists/MyList")
Dim listItems As SPListItemCollection = list.Items

Dim item As SPListItem
For Each item In listItems
    If CStr(item("Title")) = "MyValue" Then
        Dim versions As SPListItemVersionCollection = item.Versions

        If versions.Count > 1 Then
            versions.Restore(1)
        End If
    End If 
Next item
SPList oList = new SPSite("http://MySiteCollection").AllWebs["MyWebSite"].GetList("http://MySiteCollection/MyWebSite/Lists/MyList");

SPListItemCollection collListItems = oList.Items;

foreach (SPListItem oListItem in collListItems)
{
    if ((string)oListItem["Title"] == "MyValue")
    {
        SPListItemVersionCollection collListItemVersions = 
            oItem.Versions;

        if (collListItemVersions.Count > 1)
        {
            collListItemVersions.Restore(1);
        }
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

請參閱

參照

SPListItemVersionCollection members

Microsoft.SharePoint namespace