Object references in WinForms PropertyGrids
Say I have a class called StaffMember
and it has a member variable of type Position
.
If I have an enum which defines all possible positions, then when I load the StaffMember object into my PropertyGrid
, I can see a drop-down box allowing me to select from the positions defined in my enum.
However, I do not know all the different types of positions - and they can change from week to week - or even at runtime for that matter.
So I don't have a static enum with positions: instead I have a List<Position>
which contains the current list which can be added to, changed, etc.
When I put my StaffMember object with a List variable into the PropertyGrid, the Position variable is disabled and I am unable to set/m开发者_JS百科odify it.
Is it possible to get this to work, or am I doing something fundamentally wrong/impossible?
Looks like you want an UI Type Editor ...
have a look at this:
http://msdn.microsoft.com/en-us/library/ms171840.aspx
精彩评论