DisplayNameAttribute Class
Assembly: System (in system.dll)
'Declaration <AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Event)> _ Public Class DisplayNameAttribute Inherits Attribute 'Usage Dim instance As DisplayNameAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Event) */ public class DisplayNameAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Event) public class DisplayNameAttribute extends Attribute
Not applicable.
The default is the name of the property or event. The default implementation of GetSortedActionItems uses reflection to search the public properties and public void methods that take no arguments. GetSortedActionItems searches for the DisplayNameAttribute on each property and method and, if found, uses that string instead of the property or method name.
The following code example demonstrates using the DisplayNameAttribute class to change the name of a property called MisnamedProperty to RenamedProperty in a PropertyGrid control. For a full code listing, see How to: Apply Attributes in Windows Forms Controls.
' This property exists only to demonstrate the ' DisplayName attribute. When this control ' is attached to a PropertyGrid control, the ' property will be appear as "RenamedProperty" ' instead of "MisnamedProperty". <Description("Demonstrates DisplayNameAttribute."), _ DisplayName("RenamedProperty")> _ Public ReadOnly Property MisnamedProperty() As Boolean Get Return True End Get End Property
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.