SPField.FieldReferences property
Obtém uma matriz de cadeia de caracteres que contém os nomes internos dos campos que são referenciados em um campo calculado.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaração
Public ReadOnly Property FieldReferences As String()
Get
'Uso
Dim instance As SPField
Dim value As String()
value = instance.FieldReferences
public string[] FieldReferences { get; }
Property value
Type: []
Retorna String.
Examples
O exemplo de código a seguir exibe os nomes internos dos campos que envolvem as referências de campo.
O exemplo pressupõe a existência de uma página. aspx que contém um controle label.
Este exemplo requer using diretivas (Imports no Visual Basic) para os namespaces Microsoft.SharePoint e Microsoft.SharePoint.Utilities .
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();
Dica
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.