SPWeb.SiteGroups 属性

Gets a collection that contains all the groups in the site collection.

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public ReadOnly Property SiteGroups As SPGroupCollection
    Get
用法
Dim instance As SPWeb
Dim value As SPGroupCollection

value = instance.SiteGroups
public SPGroupCollection SiteGroups { get; }

属性值

类型:Microsoft.SharePoint.SPGroupCollection
A collection of SPGroup objects that represent the groups in the site collection.

示例

The following code example uses the SiteGroups property to return the collection of groups in the current site collection, and also displays the name of each group.

This example requires using directives (Imports in Microsoft Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.

Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Site_Name")
    Dim myGroups As SPGroupCollection = webSite.SiteGroups

    For Each group As SPGroup In myGroups
        Response.Write((SPEncode.HtmlEncode(group.Name) + "<BR>"))
    Next group
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
    SPGroupCollection collGroups = oWebsite.SiteGroups;
    foreach (SPGroup oGroup in collGroups)
    {
        Response.Write(SPEncode.HtmlEncode(oGroup.Name) + "<BR>");
    }
}

备注

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

另请参阅

引用

SPWeb 类

SPWeb 成员

Microsoft.SharePoint 命名空间

Groups