Hi,

I want to allow design time modification of components on a usercontrol. I
added a listview called listView1 to the usercontrol, then added this
accessor method:

[Category("Components"),
Description("Set the listview parameters."),

DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyListView ListView
{
get { return listView1; }
}

This works great, almost. When the usercontrol is added to a form, I can
edit the ListView properties. Unfortunately, this line of coded is added to
my form's InitializeComponent() method:

this.userListView.Controls.Add(this.listView1.ListView);

I've read that usually you have to expose each property individually, but
exposing the entire control works except for the redundant "Add" above. And
with DesignerSerializationVisibility.Content I didn't expect the control
itself to be serialized, just the contents. If I delete the line above
everything is fine, but of course I don't want to have to edit
InitializeComponent().

Is there a way to eliminate the redundant listview "Add()"?

Thank you,
Gary

Re: Exposing usercontrol components at design time by Atul

Atul
Wed Oct 19 05:43:03 CDT 2005

You can try applying the DesignerSerializationVisibility.Hidden attribute to
the Controls property of your USerControl.

----------------
-Atul, Sky Software http://www.ssware.com
Shell MegaPack For .Net & ActiveX
Windows Explorer GUI Controls
&
Quick-Launch Like Appbars, MSN/Office2003 Style Popups,
System Tray Icons and Shortcuts/Internet Shortcuts
----------------



"GP" <GP@discussions.microsoft.com> wrote in message
news:6F382B48-8376-4944-853B-592C8D73B46C@microsoft.com...
> Hi,
>
> I want to allow design time modification of components on a usercontrol. I
> added a listview called listView1 to the usercontrol, then added this
> accessor method:
>
> [Category("Components"),
> Description("Set the listview parameters."),
>
> DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
> public MyListView ListView
> {
> get { return listView1; }
> }
>
> This works great, almost. When the usercontrol is added to a form, I can
> edit the ListView properties. Unfortunately, this line of coded is added
> to
> my form's InitializeComponent() method:
>
> this.userListView.Controls.Add(this.listView1.ListView);
>
> I've read that usually you have to expose each property individually, but
> exposing the entire control works except for the redundant "Add" above.
> And
> with DesignerSerializationVisibility.Content I didn't expect the control
> itself to be serialized, just the contents. If I delete the line above
> everything is fine, but of course I don't want to have to edit
> InitializeComponent().
>
> Is there a way to eliminate the redundant listview "Add()"?
>
> Thank you,
> Gary
>



Re: Exposing usercontrol components at design time by GP

GP
Thu Oct 20 10:07:07 CDT 2005

Wow! That seems to do what I need! The name of the UserControl listview does
not get updated in the properties window until I reload the form, but I can
live with that given how simple the solution is.

I applied the DesignerSerializationVisibility.Hidden using the following
code - is this the proper way to do it?

Thanks so much,
Gary

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public new ControlCollection Controls
{
get
{
return base.Controls;
}
}

"Atul" wrote:

> You can try applying the DesignerSerializationVisibility.Hidden attribute to
> the Controls property of your USerControl.
>
> ----------------
> -Atul, Sky Software http://www.ssware.com
> Shell MegaPack For .Net & ActiveX
> Windows Explorer GUI Controls
> &
> Quick-Launch Like Appbars, MSN/Office2003 Style Popups,
> System Tray Icons and Shortcuts/Internet Shortcuts
> ----------------
>
>
>
> "GP" <GP@discussions.microsoft.com> wrote in message
> news:6F382B48-8376-4944-853B-592C8D73B46C@microsoft.com...
> > Hi,
> >
> > I want to allow design time modification of components on a usercontrol. I
> > added a listview called listView1 to the usercontrol, then added this
> > accessor method:
> >
> > [Category("Components"),
> > Description("Set the listview parameters."),
> >
> > DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
> > public MyListView ListView
> > {
> > get { return listView1; }
> > }
> >
> > This works great, almost. When the usercontrol is added to a form, I can
> > edit the ListView properties. Unfortunately, this line of coded is added
> > to
> > my form's InitializeComponent() method:
> >
> > this.userListView.Controls.Add(this.listView1.ListView);
> >
> > I've read that usually you have to expose each property individually, but
> > exposing the entire control works except for the redundant "Add" above.
> > And
> > with DesignerSerializationVisibility.Content I didn't expect the control
> > itself to be serialized, just the contents. If I delete the line above
> > everything is fine, but of course I don't want to have to edit
> > InitializeComponent().
> >
> > Is there a way to eliminate the redundant listview "Add()"?
> >
> > Thank you,
> > Gary
> >
>
>
>