PropertyGridObject.GetDisplayNameAttribute(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the display name attribute for a property, event, or public void method that takes no arguments.
protected:
System::ComponentModel::DisplayNameAttribute ^ GetDisplayNameAttribute(System::String ^ friendlyName, System::String ^ configPropertyName);
protected System.ComponentModel.DisplayNameAttribute GetDisplayNameAttribute (string friendlyName, string configPropertyName);
member this.GetDisplayNameAttribute : string * string -> System.ComponentModel.DisplayNameAttribute
Protected Function GetDisplayNameAttribute (friendlyName As String, configPropertyName As String) As DisplayNameAttribute
Parameters
- friendlyName
- String
The description of the property.
- configPropertyName
- String
The configuration name of the property.
Returns
The DisplayNameAttribute object for a property, event, or public void method that takes no arguments.
Examples
The following example uses the GetDisplayNameAttribute method to provide information about the calling object.
protected override PropertyDescriptorCollection
GetProperties(Attribute[] attributes) {
PropertyDescriptorCollection PDC =
base.GetProperties(attributes);
ArrayList properties = new ArrayList();
Type thisType = GetType();
foreach (PropertyDescriptor pd in PDC) {
AttributeCollection attributCol = pd.Attributes;
// Display Name Attribute (DNA)
MyDNAttribute dna = (MyDNAttribute)
(attributCol[typeof(MyDNAttribute)]);
if (dna != null) {
DisplayNameAttribute newDNA =
GetDisplayNameAttribute(
dna.Description,
String.Empty
);
properties.Add(
TypeDescriptor.CreateProperty(
thisType, pd, newDNA
));
} else {
properties.Add(pd);
}
}
PDC = new PropertyDescriptorCollection((PropertyDescriptor[])
properties.ToArray(typeof(PropertyDescriptor)));
return PDC;
}
Remarks
You can override this method to modify the properties of the System.ComponentModel.DisplayNameAttribute object before the properties are shown in the property grid.