SPView.ViewFields property
取得檢視中使用的檢視欄位。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property ViewFields As SPViewFieldCollection
Get
'用途
Dim instance As SPView
Dim value As SPViewFieldCollection
value = instance.ViewFields
public SPViewFieldCollection ViewFields { get; }
Property value
Type: Microsoft.SharePoint.SPViewFieldCollection
SPViewFieldCollection 物件,表示檢視的欄位。
備註
如需有關檢視欄位的詳細資訊,請參閱ViewFields項目。
Examples
下列程式碼範例使用ViewFields屬性來傳回集合的檢視欄位中的所有項目清單的檢視,並將新的 [檢視] 欄位加入至集合。
Dim siteColl As SPSite = SPControl.GetContextSite(Context)
Dim site As SPWeb = siteColl.AllWebs("Site_Name")
Dim list As SPList = site.Lists("List_Name")
Dim view As SPView = list.Views("All Items")
Dim viewFields As SPViewFieldCollection = view.ViewFields
viewFields.Add("Created")
view.Update()
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
{
SPList oList = oWebsite.Lists["List_Name"];
SPView oView = oList.Views["All Items"];
SPViewFieldCollection collViewFields = oView.ViewFields;
collViewFields.Add("Created");
oView.Update();
}
注意事項 |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |