共用方式為


SPField.Title Property

Gets or sets the display name for the field.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableAttribute> _
Public Property Title As String
    Get
    Set
'Usage
Dim instance As SPField
Dim value As String

value = instance.Title

instance.Title = value
[ClientCallableAttribute]
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