c# - Dispaying and editing a sub property of a property in PropertyGrid -


i no longer find exact solution problem in internet i'm asking question. hope may able me.

i have following classes:

public item  {     public fieldtype myfield { get; set; }     public string description { get; set; }     public int capacity { get; set; } }  public fieldtype  {     public string value { get; set; }     public string fieldcode { get; set; }     public string tablecode { get; set; } } 

in form, created instance of item class. contains following members:

  • myfield (type of fieldtype)
  • description (type of string)
  • capacity (an int)

is possible show value member of myfield property in propertygrid?

below how assign selected object property of propertygrid.

void form1(object sender, eventargs e) {     propertygrid1.selectedobject = new item();           } 

yes, easy:
add computed read property item

public item  {    public fieldtype myfield { get; set; }    public string myfieldvalue => myfield.value;    public string description { get; set; }    public int capacity { get; set; } } 

Comments