Designer serialization of protected properties in derived classes
- From: "robrich" <robrich@xxxxxxxxxxxxxxxx>
- Date: Tue, 2 Aug 2005 00:42:03 -0700
I'm using Visual Studio 2003 on a Windows XP machine. I've tried this in
various circumstances, and narrowed it down to this simple example:
I've got a base form called BaseForm defined like so:
public class BaseForm : System.Windows.Forms.Form { ...
It has a protected property called "MainPanel" which looks like so:
protected Panel MainPanel {
get { return this.mainPanel; }
}
this.mainPanel is a Panel that works perfectly in design mode on BaseForm.
I've got a class that derives from BaseForm defined like so:
public class DerivedForm : BaseForm { ...
I can drop controls onto DerivedForm onto MainPanel in design mode, all is
well. I look at the Designer Generated Code, and they aren't added to
MainPanel's Control array. I can add code like this, and it works ok:
this.MainPanel.Controls.Add(this.label1);
Every time I make a change in the DerivedForm in design mode, it re-creates
the Designer Generated Code, removes my MainPanel.Controls.Add line, and a
subsequent build removes the controls from the form.
I've tried adding these designer attributes to the protected MainPanel
definition to no avail:
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true)
]
protected Panel MainPanel {
get { return this.mainPanel; }
}
It has become quite a chore to re-add all the
this.MainPanel.Add(this.Control); lines back in every time. How do I get the
designer to serialize protected properties like this?
robrich
robrich@xxxxxxxxxxxxxxxx
.
- Follow-Ups:
- RE: Designer serialization of protected properties in derived classes
- From: "Jeffrey Tan[MSFT]"
- RE: Designer serialization of protected properties in derived classes
- Prev by Date: Re: Imagelist causes TargetInvocationException at runtime
- Next by Date: RE: Designer serialization of protected properties in derived classes
- Previous by thread: Imagelist causes TargetInvocationException at runtime
- Next by thread: RE: Designer serialization of protected properties in derived classes
- Index(es):
Relevant Pages
|