次の方法で共有


SPField.Title property

Gets or sets the display name for the field.

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

Syntax

'Declaration
Public Property Title As String
    Get
    Set
'Usage
Dim instance As SPField
Dim value As String

value = instance.Title

instance.Title = value
public string Title { get; set; }

Property value

Type: System.String
A string that contains the display name.

Remarks

The value that is returned can vary depending on the current thread's Thread.CurrentUICulture property. For more information, see the TitleResource property.

Examples

The following example is a console application that iterates through the list of cultures supported by a Web site and sets the current thread's CurrentUICulture to each one, in turn. For each supported culture, the application prints the name of the culture and the value of the Title property in that culture.

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)
                {
                    SPField field = web.AvailableFields[SPBuiltInFieldId.User];

                    string formatString = "{0, -20} {1}";
                    Console.WriteLine(formatString, "CurrentUICulture", "Title");

                    foreach (CultureInfo culture in web.SupportedUICultures)
                    {
                        Thread.CurrentThread.CurrentUICulture = culture;
                        Console.WriteLine(formatString, culture.Name, field.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 field As SPField = web.AvailableFields(SPBuiltInFieldId.User)

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

                For Each culture As CultureInfo In web.SupportedUICultures
                    Thread.CurrentThread.CurrentUICulture = culture
                    Console.WriteLine(formatString, culture.Name, field.Title)
                Next

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

End Module

See also

Reference

SPField class

SPField members

Microsoft.SharePoint namespace

TitleResource