SPWeb.SiteGroups property
取得集合,其中包含網站集合中的所有群組。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property SiteGroups As SPGroupCollection
Get
'用途
Dim instance As SPWeb
Dim value As SPGroupCollection
value = instance.SiteGroups
public SPGroupCollection SiteGroups { get; }
Property value
Type: Microsoft.SharePoint.SPGroupCollection
代表網站集合中的群組的SPGroup物件的集合。
Examples
下列程式碼範例會使用SiteGroups屬性來傳回在目前的網站集合中,群組的集合,也會顯示每個群組名稱。
這個範例要求using指示詞 (Imports Microsoft Visual Basic 中), Microsoft.SharePoint和Microsoft.SharePoint.Utilities命名空間。
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>");
}
}
![]() |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |