469,625 Members | 1,722 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

adding designtime support for property of usercontrol (InitializeComponents)

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 ?

Aug 16 '06 #1
1 2828
Try adding the DesignerSerializationVisibility attribute

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

/claes

"bonk" <sc******************@gmx.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>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 ?

Aug 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by dan | last post: by
reply views Thread by Dst | last post: by
3 posts views Thread by arncota | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.