
Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Hi Mick,
Well, now run as well but for me is clear why.
Is possible explains me and at the group when is possible use the
DesignerSerializationVisibility and the SouldSerializeMethod ways?
I think the second the have necessity to redefine a base.Method?
Thank's in advance,
-- Andrea Gelati
> \\\
> private Color faceColor = Color.Empty;
[quoted text clipped - 49 lines]
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.775 / Virus Database: 522 - Release Date: 08/10/2004
Frank Hileman - 16 Oct 2004 23:13 GMT
DesignerSerializationVisibility is to specify if something should be
serialized at all, or if set to "Content", it means you should serialize the
things "inside" and not the thing itself. For example, the Controls
collection would be Content, as the collection itself is not serialized, but
the objects in it are.
ShouldSerialize (and Reset if you want to be friendly) are needed if the
"default" value cannot be expressed as a constant, either because it is an
object reference, or because it is determined dynamically.
There are articles in the MSDN discussing these.
Regards,
Frank Hileman
check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
> Hi Mick,
>
[quoted text clipped - 8 lines]
>
> -- Andrea Gelati
Mick Doherty - 16 Oct 2004 23:48 GMT
We used the ShouldSerialize method because we wanted Ambient property
behaviour. In other words we want our BackColor property to return the
parent controls BackColor if we do not specify a color. We supplied the
AmbientValue attribute to the property for proper behaviour in the IDE.
Comment out the attribute, rebuild the control and change the property in
the IDE. You should visually see the result in your control. Now right click
on the property and choose Reset. The property will reset to the parent's
BackColor, but you will see no Visual effect of this in your control until
it is invalidated. Now uncomment the attribute and repeat these same steps
and you should see the Control is invalidated upon Reset.
In the following example we do not use the ShouldSerialize method but the
property is serialized if it is not at it's default value of
SystemColors.Control. If we do not supply the DefaultValue attribute then
the property will always be serialized.
Also note that this property does not follow the Parents Background property
since we have used a static value to define the default value.
\\\
private Color faceColor = SystemColors.Control;
[DefaultValue(typeof(Color),"Control")]
public new Color BackColor
{
get
{
return faceColor;
}
set
{
faceColor = value;
this.Invalidate();
}
}
///
Use the DesignerSerializationVisibility attribute to get the code generator
to serialize your property if it returns a type that does not have a
serializer.

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
> Hi Mick,
>
[quoted text clipped - 62 lines]
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.775 / Virus Database: 522 - Release Date: 08/10/2004