adding designtime support for property of usercontrol (InitializeComponents)

  • Thread starter Thread starter bonk
  • Start date Start date
B

bonk

I have a very simple UserControl (derived from
System.Windows.Forms.UserControl) that contains several ListViews. The
UserControl exposes a single public property:

public ListView.ColumnHeaderCollection Columns { get {...} };

When I use VS2005 designer's proprtygrid for that UserConrol to add new
Colums to the Collection everything works fine: The form that contains
the UserControl gets new members ( private
System.Windows.Forms.ColumnHeader columnHeader1, ...) in the
UserControl.Designer.cs also initializes each ColumnHeader inside
InitializeComponets().

There is one thing though that the designer fails to do: it does not
add the necessary:

this.userControl1.Columns.AddRange(new
System.Windows.Forms.ColumnHeader[]
{this.columnHeader1,this.columnHeader2,...});

into the InitializeComponent() Method in the UserControl.Designer.cs.

What do I need to do to make that happen ?
 
Try adding the DesignerSerializationVisibility attribute

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ListView.ColumnHeaderCollection Columns
{
get {...}
}

/claes
 
Back
Top