SPFieldLinkCollection.Item property (String)
索引的物件名稱,從集合中取得指定的SPFieldLink物件。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Default Property Item ( _
name As String _
) As SPFieldLink
Get
'用途
Dim instance As SPFieldLinkCollection
Dim name As String
Dim value As SPFieldLink
value = instance(name)
public SPFieldLink this[
string name
] { get; }
參數
name
Type: System.String欄位參考名稱。
Property value
Type: Microsoft.SharePoint.SPFieldLink
SPFieldLink物件。
備註
可以表示傳遞做為引數的名稱,做為Name屬性的值或DisplayName屬性的值。當您傳遞Name屬性的值時,通常會得到更可靠的結果,原因有二。首先,在集合中的沒有兩個物件中可以有相同的值 [ Name ] 屬性中,雖然兩個或多個物件可以在DisplayName屬性中有相同的值。第二, Name屬性是唯讀的因此它的值不變的而DisplayName屬性可以由具有足夠的權限的使用者進行修改。
如果找不到指定的物件,索引子會傳回 null。
Examples
下列範例會逐一查看所有的內容類型可用站台層級,尋找參考至特定網站的資料行的主控台應用程式。特別是,應用程式搜尋"電話,"站台資料行的內部名稱,而不是使用資料行的顯示名稱,[商務電話]。
Imports System
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Dim site As SPSite = New SPSite("https://localhost")
Try
Dim web As SPWeb = site.OpenWeb()
Try
Dim fldName As String = "WorkPhone"
Dim cts As SPContentTypeCollection = web.AvailableContentTypes
Dim fldLnk As SPFieldLink = Nothing
For Each ct As SPContentType In cts
fldLnk = ct.FieldLinks(fldName)
If fldLnk IsNot Nothing Then
Console.WriteLine("Content type {0} links to the {1} field", _
ct.Name, fldName)
End If
Next ct
Finally
web.Dispose()
End Try
Finally
site.Dispose()
End Try
Console.Write("Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
string fldName = "WorkPhone";
SPContentTypeCollection cts = web.AvailableContentTypes;
SPFieldLink fldLnk = null;
foreach (SPContentType ct in cts)
{
fldLnk = ct.FieldLinks[fldName];
if (fldLnk != null)
{
Console.WriteLine("Content type {0} links to the {1} field", ct.Name, fldName);
}
}
}
}
Console.Write("Press ENTER to continue...");
Console.ReadLine();
}
}
}
請參閱
參照
Microsoft.SharePoint namespace