Looking for a way to dynamically change field names in PropertyGrid
See the question and my original answer on StackOverflowWhat you could do is reuse the DynamicTypeDescriptor class described in my answer to this question here on SO: PropertyGrid Browsable not found for entity framework created property, how to find it?
like this:
DynamicTypeDescriptor dtp = new DynamicTypeDescriptor(typeObj);
// get current property definition and remove it
var current = dtp.Properties["ThePropertyToChange"];
dtp.RemoveProperty("ThePropertyToChange");
// add a new one, but change its display name
DynamicTypeDescriptor.DynamicProperty prop = new DynamicTypeDescriptor.DynamicProperty(dtp, current, obj);
prop.SetDisplayName("MyNewPropertyName");
dtp.AddProperty(prop);
propertyGrid1.SelectedObject = dtp.FromComponent(obj);