SPWeb.Groups property
取得集合,其中包含的網站的所有群組。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property Groups As SPGroupCollection
Get
'用途
Dim instance As SPWeb
Dim value As SPGroupCollection
value = instance.Groups
public SPGroupCollection Groups { get; }
Property value
Type: Microsoft.SharePoint.SPGroupCollection
SPGroup 物件的集合。
Examples
下列程式碼範例會使用Groups屬性,來傳回目前的網站集合中指定的站台的群組的集合。
這個範例要求using指示詞 (Imports Microsoft Visual Basic 中), Microsoft.SharePoint和Microsoft.SharePoint.Utilities命名空間。
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL")
Dim groups As SPGroupCollection = webSite.Groups
For Each group As SPGroup In groups
Response.Write((SPEncode.HtmlEncode(group.Name) + "<BR>"))
Next group
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
SPGroupCollection collGroups = oWebsite.Groups;
foreach (SPGroup oGroup in collGroups)
{
Response.Write(SPEncode.HtmlEncode(oGroup.Name) + "<BR>");
}
}
![]() |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |