adding designtime support for property of usercontrol (InitializeComponents)

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 ?
 
C

Claes Bergefall

Try adding the DesignerSerializationVisibility attribute

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

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top