views:

14

answers:

0

Can/Should a derived Component class have a property of type another derived Component type?

I have a RecordComponent that derives from System.ComponentModel.Component. It has three properties DeleteCmd, SaveCmd, and BoundCmd. Those properties are of type DeleteCommand, SaveCommand, and BoundCommand respectively. DeleteCommand and SaveCommand derive from BoundCommand. And BoundCommand derives from CommandComponent which derives from Component.

I also have a MyButton class which derives from System.Windows.Forms.Button. It has one property Command of type CommandComponent.

I found that if I decorate the RecordComponent properties DeleteCmd, SaveCmd, and BoundCmd with DesignerSerializationVisibility(DesignerSerializationVisibility.Content) then they will be listed in the MyButton.Command drop down list in the PropertyGrid if the form contains a RecordComponent.

Although, only the first selected Command 'sticks'. After setting Command to the RecordComponent's SaveCommand and save and close the form designer - if you reopen the form designer and change MyButton.Command to DeleteCommand it will not serialize that change to the form's designer generated code.

I have sample sln with two projects that demonstrates this issue.

Has anyone else experienced a simular issue of not being able to change a properties value once set?

Any help or ideas appreciated. Thanks, Rusty