Implementing sub fields in a PropertyGrid

Posted by evolve on Stack Overflow See other posts from Stack Overflow or by evolve
Published on 2010-05-24T15:13:53Z Indexed on 2010/06/06 19:22 UTC
Read the original article Hit count: 240

Filed under:
|
|

Alright so my terminology when it comes to C# isn't great, so I'll attempt to explain this with a small example. If you create a class which you are using within a PropertyGrid and you have the following values:

class Test
{
    public Point example { get; set; }
}

This will produce a PropertyGrid which has an expandable object "example" which has fields X and Y in order to create a "Point".

I'm attempting to create an object "name" which has fields "firstname" and "lastname", so I have:

class Test
{
    public Name example { get; set; }
}

public struct Name
{
    public string firstname { get; set; }
    public string lastname { get; set; }
}

This however isn't working as intended.

I think I need to override some method(s) in order to get this working, however since I don't really have the terminology down for PropertyGrids it is difficult for me to find a solution.

Any help would be great.

© Stack Overflow or respective owner

Related posts about c#

Related posts about visual-studio