Custom Component Design Time Array Property Question. . .

note: abbreviated code for clarity

I have a class Definition that implements IDefinition -


public interface IDefinition
{
   int Width {get;set}
   string Caption{get;set}
}

 


I have an enumeration

public enum Foobar{foo, bar,}

I have a component, MyComponent that has a public Array property Definitions and FoobarType:


public MyComponent:Component
{
  private Definitions[] _defs = new Definition[]{new Definition(),new Definition()};
  private Foobar _foobar = Foobar.foo;

  [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  public Definitions[] Definitions 
  {
    get { return _defs;}
    set { _defs = values;}
  } 
 
  public Foobar FoobarType 
  {
    get {return _foobar;}
    set
    {
      if ( (_defs !=null) && (_foobar==value)) return;
      switch (_foobar)
      {
        case Foobar.foo:
          /* Make two definitions */
          _defs = new Definitions[]{new Definitions(),new Definitions()};
               break;
        case Foobar.bar: 
          /* Make one definition */
          _defs = new Definitions[]{new Definitions(),new Definitions()};
          break;
      }
    }
  }
}

 


the idea is. . . when in designmode, if I choose to set the FooBarType to foo, I want Two definitions, if Bar, I only want one. And I want the designer to let me set the Width and caption of the definitions. . .

the DesignerSerializationVisibility attribute lets me interface the Definitions via the designer, I want that when I change the foobartype property using the designer, the definitions reinitialize but this doesnt happen. . . .

any suggestions


Answer this question

Custom Component Design Time Array Property Question. . .

  • NeoDiO12639

    nevermind. . . my error was somewhere else. . .
    the example I gave was not exactly what my actual design is. . .
    the above works.



  • Custom Component Design Time Array Property Question. . .