How to display a dynamic object in property grid?

后端 未结 3 988
时光取名叫无心
时光取名叫无心 2021-01-01 04:57

I have a custom object type which has to be editable in PropertyGrid:

public class CustomObjectType
{
    public string Name { get; set; }               


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-01 05:16

    public override void SetValue(object component, object value)           
    {
        //((CustomObjectType)component)[prop.Name] = value;
    
        CustomObjectType cot = (CustomObjectType)component;
    
        CustomProperty cp = cot.Properties.FirstOrDefault(r => r.Name.Equals(prop.Name));
        if (cp == null) return;
    
        cp.DefaultValue = value;
    }
    

提交回复
热议问题