Partager via


SPList.TitleResource - Propriété

Gets an SPUserResource object that represents the translations for the title of the list.

Espace de noms :  Microsoft.SharePoint
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
Public ReadOnly Property TitleResource As SPUserResource
    Get
'Utilisation
Dim instance As SPList
Dim value As SPUserResource

value = instance.TitleResource
public SPUserResource TitleResource { get; }

Valeur de propriété

Type : Microsoft.SharePoint.SPUserResource
An object that encapsulates a user-defined localizable resource.

Remarques

This property is the source for the string returned by the Title property, which returns TitleResource.Value. The value that is returned by this expression can vary depending on the value of the CurrentUICulture of the current thread. For more information, see the SPUserResource.Value property.

Exemples

The following example is a console application that demonstrates how the TitleResource property and Title properties are related, and also how their values can change depending on the culture of the current thread. The application enumerates the list of cultures supported by a Web site and sets the current thread's Thread.CurrentUICulture property to each supported culture. The application then prints the values of the TitleResource property and the Title property for the Announcements list in the language of the thread's CurrentUICulture.

using System;
using System.Globalization;
using System.Threading;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("https://localhost"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPList list = web.Lists.TryGetList("Announcements");
                    if (list != null)
                    {
                        string formatString = "{0, -20} {1, -20} {2}";
                        Console.WriteLine(formatString, "CurrentUICulture", "TitleResource", "Title");

                        SPUserResource resource = list.TitleResource;
                        foreach (CultureInfo culture in web.SupportedUICultures)
                        {
                            Thread.CurrentThread.CurrentUICulture = culture;
                            Console.WriteLine(formatString, culture.Name, resource.Value, list.Title);
                        }
                    }
                }
            }
            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}
Imports System
Imports System.Globalization
Imports System.Threading
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()
        Using site As New SPSite("https://localhost")
            Using web As SPWeb = site.OpenWeb()

                Dim list As SPList = web.Lists.TryGetList("Announcements")
                If list IsNot Nothing Then

                    Dim formatString As String = "{0, -20} {1, -20} {2}"
                    Console.WriteLine(formatString, "CurrentUICulture", "TitleResource", "Title")

                    Dim resource As SPUserResource = list.TitleResource
                    For Each culture As CultureInfo In web.SupportedUICultures

                        Thread.CurrentThread.CurrentUICulture = culture
                        Console.WriteLine(formatString, culture.Name, resource.Value, list.Title)

                    Next

                End If

            End Using
        End Using
        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub

End Module

Voir aussi

Référence

SPList classe

SPList - Membres

Microsoft.SharePoint - Espace de noms

Title

UserResources