共用方式為


SPField.FieldReferences property

取得包含內部參照計算欄位中的欄位名稱的字串陣列。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public ReadOnly Property FieldReferences As String()
    Get
'用途
Dim instance As SPField
Dim value As String()

value = instance.FieldReferences
public string[] FieldReferences { get; }

Property value

Type: []
傳回 String

Examples

下列程式碼範例會顯示內部涉及欄位參照的欄位名稱。

此範例假設有一個包含 label 控制項的.aspx 頁面。

這個範例需要Microsoft.SharePointMicrosoft.SharePoint.Utilities命名空間using指示詞 (在 Visual Basic 中的Imports )。

Dim site As SPSite = SPContext.Current.Site
Dim web As SPWeb = site.AllWebs("Site_Name")
Dim fields As SPFieldCollection = web.Lists("List_Name").Fields
Dim i As Integer

For i = 0 To fields.Count - 1

    Dim refFields As String() = fields(i).FieldReferences

    If Not (refFields Is Nothing) Then

        Dim j As Integer

        For j = 0 To refFields.Length - 1

            Label1.Text += SPEncode.HtmlEncode(refFields(j)) & "<BR>"

        Next j

    End If

Next i
SPSite oSiteCollection = SPContext.Current.Site;
SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name"];
SPFieldCollection collFields = oWebsite.Lists["List_Name "].Fields;

for (int intIndex=0; intIndex<collFields.Count; intIndex++)
{
    string[] strRefFields = collFields[intIndex].FieldReferences;

    if (strRefFields != null)
    {
        for (int intStrPos=0; intStrPos<strRefFields.Length; intStrPos++)
        {
            Label1.Text += SPEncode.HtmlEncode(strRefFields[intStrPos]) + "<BR>";
        }
    }
}
oWebsite.Dispose();
注意事項注意事項

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.

請參閱

參照

SPField class

SPField members

Microsoft.SharePoint namespace