WebDisplayNameAttribute 建構函式

定義

初始化 WebDisplayNameAttribute 類別的新執行個體。

多載

WebDisplayNameAttribute()

不使用指定的名稱,初始化 WebDisplayNameAttribute 類別的新執行個體。

WebDisplayNameAttribute(String)

使用指定的顯示名稱,初始化 WebDisplayNameAttribute 類別的新執行個體。

WebDisplayNameAttribute()

不使用指定的名稱,初始化 WebDisplayNameAttribute 類別的新執行個體。

public:
 WebDisplayNameAttribute();
public WebDisplayNameAttribute ();
Public Sub New ()

備註

WebDisplayNameAttribute 構函式會將 DisplayName 屬性設定為空字串 (「」) 。

適用於

WebDisplayNameAttribute(String)

使用指定的顯示名稱,初始化 WebDisplayNameAttribute 類別的新執行個體。

public:
 WebDisplayNameAttribute(System::String ^ displayName);
public WebDisplayNameAttribute (string displayName);
new System.Web.UI.WebControls.WebParts.WebDisplayNameAttribute : string -> System.Web.UI.WebControls.WebParts.WebDisplayNameAttribute
Public Sub New (displayName As String)

參數

displayName
String

要用於 PropertyGridEditorPart 中的易記名稱。

範例

下列程式碼範例示範如何使用 WebDisplayNameAttribute 屬性,將顯示名稱指派給Web 組件控制項上的屬性。 自訂 UserJobType 屬性會提供易記名稱 「作業類型」,以顯示在 控制項中 PropertyGridEditorPart 。 名稱是透過 WebDisplayNameAttribute 建構函式指派。 此範例是類別概觀中找到較大範例的 PropertyGridEditorPart 一部分。

[Personalizable(), WebBrowsable(), WebDisplayName("Job Type"), 
  WebDescription("Select the category that corresponds to your job.")]
public JobTypeName UserJobType
{
  get
  {
    object o = ViewState["UserJobType"];
    if (o != null)
      return (JobTypeName)o;
    else
      return _userJobType;
  }

  set { _userJobType = (JobTypeName)value; }
}
<Personalizable(), WebBrowsable(), WebDisplayName("Job Type"), _
  WebDescription("Select the category that corresponds to your job.")> _
Public Property UserJobType() As JobTypeName
  Get
    Dim o As Object = ViewState("UserJobType")
    If Not (o Is Nothing) Then
      Return CType(o, JobTypeName)
    Else
      Return _userJobType
    End If
  End Get
  Set(ByVal value As JobTypeName)
    _userJobType = CType(value, JobTypeName)
  End Set
End Property

備註

WebDisplayNameAttribute 構函式會將 DisplayName 屬性設定為 displayName 。 參數 displayName 是出現在 控制項中的 PropertyGridEditorPart 值。

適用於