dotnet windows forms designtime:
My custom composite control for the .NET Compact Framework will not serialize
the DesignTime DefaultValues I assign to properties. For instance, VS
serializes '0' for ints and it serializes the first value for any enumeration
types.
For example:
// I implemented this default value via the “Custom Attributes
// Form†or through DesignTimeAttributes.xmta rather.
[DefaultValue(2)]
public int ButtonCount
{
get{ return count;}
set{ count = value;}
}
Considering the code snippet above you’d think the designer would serialize
the following…
Obj.ButtonCount = 2; // I would assume this serialization because
DefaultValue(2)
But instead I get…
Obj.ButtonCount = 0;
I can change the value of the property and the code reflects the change
correctly, but the designer doesn’t initially serialize the default value to
the property in InitializeComponents. Consequently, when I change the
property value manually via the property grid to the default value, the
designer recognizes this and no longer serializes the property setting in
InitializeComponents.
Also, if I have:
Public enum PanelType
{
NO_PANEL,
BOTTOM_PANEL,
TOP_PANEL
};
[DefaultValue(BOTTOM_PANEL)]
Public PanelType FormPanelType
{
get{ return pType; }
set{ pType = value;}
}
Here the same sort of issue arises … the designer only serializes NO_PANEL
initially, and disregards the DefaultValue. Consequently, when the default
value is selected manually the default value isn’t recognized by the designer
and the default value setting is still serialized in InitializeComponents.
This differs from the ‘int’ property above…
I’ve looked at many examples, and I am still unable to find the exact
configuration settings for this issue.
Any thoughts?
thanks