Compartilhar via


SPFieldLinkCollection.Item property (Guid)

Obtém o objeto especificado SPFieldLink da coleção usando seu identificador (ID).

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

Syntax

'Declaração
Public ReadOnly Default Property Item ( _
    id As Guid _
) As SPFieldLink
    Get
'Uso
Dim instance As SPFieldLinkCollection
Dim id As Guid
Dim value As SPFieldLink

value = instance(id)
public SPFieldLink this[
    Guid id
] { get; }

Parâmetros

  • id
    Type: System.Guid

    O valor da propriedade Id do objeto SPFieldLink para recuperar.

Property value

Type: Microsoft.SharePoint.SPFieldLink
Um objeto SPFieldLink .

Comentários

Se o objeto especificado não for encontrado, o indexador retorna null.

Examples

O exemplo a seguir mostra um aplicativo de console que itera por meio de tipos de conteúdo que estão disponíveis no nível do site, procurando referências a uma coluna de site em particular.

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"
                Try
                    Dim fld As SPField = web.Fields.GetField(fldName) 'Throws exception if field not found
                    For Each ct As SPContentType In web.AvailableContentTypes
                        Dim fldLnk As SPFieldLink = ct.FieldLinks(fld.Id)
                        If fldLnk IsNot Nothing Then
                            Console.WriteLine("Content type {0} links to the {1} field.", _
                                              ct.Name, fldName)
                        End If
                    Next ct
                Catch ex As ArgumentException
                    Console.WriteLine("ArgumentException thrown by {0}.", ex.TargetSite)
                    Console.WriteLine("Argument passed to GetField is '{0}'.", fldName)
                End Try
            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";
                    try
                    {
                        SPField fld = web.Fields.GetField(fldName); // Throws exception if field not found
                        foreach (SPContentType ct in web.AvailableContentTypes)
                        {
                            SPFieldLink fldLnk = ct.FieldLinks[fld.Id];
                            if (fldLnk != null)
                            {
                                Console.WriteLine("Content type {0} links to the {1} field.",
                                                  ct.Name, fldName);
                            }
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine("ArgumentException thrown by {0}.", ex.TargetSite);
                        Console.WriteLine("Argument passed to GetField is '{0}'.", fldName);
                    }
                }
            }
            Console.Write("Press ENTER to continue...");
            Console.ReadLine();
        }
    }
}

Ver também

Referência

SPFieldLinkCollection class

SPFieldLinkCollection members

Item overload

Microsoft.SharePoint namespace

SPFieldLink

SPContentType

Outros recursos

Fields and Field References

Introduction to Columns