Why SomeClass.ClassField.StructField property doesn\'t change in a propertyGrid?
It seems, propertyGrid doesn\'t call SomeClass.
In my case, the generic argument isn't known at compile time (options structure for a plugin). You can get a copy of the current value using context.PropertyDescriptor.GetValue(context.Instance); :
public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
{
if (propertyValues == null)
throw new ArgumentNullException("propertyValues");
object boxed = context.PropertyDescriptor.GetValue(context.Instance);
foreach (DictionaryEntry entry in propertyValues)
{
PropertyInfo pi = boxed.GetType().GetProperty(entry.Key.ToString());
if (pi != null && pi.CanWrite)
pi.SetValue(boxed, Convert.ChangeType(entry.Value, pi.PropertyType), null);
}
return boxed;
}