views:

131

answers:

2

I have a control that has a list of Rods. The Rods have a few public properties:


    public class Rod
    {
     float Angle { get; set; }
     Color MainColour { get; set; }
     int Length { get; set; }
     int Width { get; set; }
        //other private code here you need not be concerned with ;)
    }

In the control that hosts the Rods, the list is declared as:

public List<Rod> Rods { get; set; }

I would like to be able to select a RodsHost control and click on the "Rods" property page, and edit the Rods on that control through the Forms Designer GUI. Currently, I can add Rods to the list, but not edit the Rod's properties (Angle, MainColour, etc...). I tried applying the attribute [DesignTimeVisible(true)] to the Rods class, that didn't seem to work. I thought maybe I should use the Designer attribute, but I'm not sure which Designer class I need here. Anyone got a suggestion?

+1  A: 

I don't know if this helps you out or not but what I did was create a userControl and within it created the properties as get set. The properties then showed up automatically in the Properties pane in the visual IDE.

Sergio Tapia
I tried that but it doesn't seem to have worked. The regular properties inherited from Control appear in the Properties pane when I edit the list, but the custom ones I added didn't show up.
FrustratedWithFormsDesigner
A: 

It looks like I needed to decorate the list as:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

as well as add a constructor to set some appropriate default values.

FrustratedWithFormsDesigner