Hi,
It is possible to do it.
The DescriptionAttribute has a public property "Description" which is ReadOnly, It also has a "DescriptionValue" whick is protected read/write. We can access this "DescriptionValue" property via Reflection. Here's how in C# :
It is possible to do it.
The DescriptionAttribute has a public property "Description" which is ReadOnly, It also has a "DescriptionValue" whick is protected read/write. We can access this "DescriptionValue" property via Reflection. Here's how in C# :
Type myType = _propertyGrid.SelectedObject.GetType();
PropertyDescriptor descriptor = TypeDescriptor.GetProperties( myType )[ "Temperature" ];
DescriptionAttribute desc = descriptor.Attributes.OfType<DescriptionAttribute>().FirstOrDefault();
if( desc != null )
{
PropertyInfo propertyInfo = desc.GetType().GetProperty( "DescriptionValue", BindingFlags.NonPublic | BindingFlags.Instance );
propertyInfo.SetValue( desc, "Enter temperature (°F)", null );
//A refresh on the PropertyGrid is needed to Regenerate the properties.
object saveData = _propertyGrid.SelectedObject;
_propertyGrid.SelectedObject = null;
_propertyGrid.SelectedObject = saveData;
}