SPField.Title 属性

获取或设置字段的显示名称。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Property Title As String
    Get
    Set
用法
Dim instance As SPField
Dim value As String

value = instance.Title

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

属性值

类型:System.String
一个字符串,包含的显示名称。

备注

根据当前线程的Thread.CurrentUICulture属性,则返回的值会有所不同。有关详细信息,请参阅TitleResource属性。

示例

下面的示例是一个控制台应用程序,循环访问网站支持的区域性的列表,并将当前线程的CurrentUICulture设置为每个反过来。为每个受支持的区域性,应用程序打印的区域性名称和该区域性中Title属性的值。

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

另请参阅

引用

SPField 类

SPField 成员

Microsoft.SharePoint 命名空间

TitleResource