design-time issue with user control

G

Guest

Hello experts.

Description:
My problem occurs under the following assumptions:

- I created a class called 'VisualAspect', which contains generic
properties such as BackColor, ForeColor, FontData, BorderStyle, etc.
-- I implemented a TypeConverter for this class that returns a
constructor-based
instance descriptor.
-- I have designated every property with default values, and for those
properties that cannot implement default values, I implemented the
ShouldSerializePropName and ResetPropName methods.

- I created a user control that contains several VisualAspect properties.
-- Every instance of a VisualAspect object contained by the control is
private.
-- Every instance of the VisualAspect objects are publicly exposed via
properties (get & set) with 'Content' as the DesignerSerializationVisibility
attribute.
-- The control's constructor initializes all VisualAspect objects with
new instances, thereby providing base, default, values.

The problem:
- I notice in the generated code that the InitializeComponent method
creates new instances of the VisualAspect objects; something that is not
necessary because the control's constructor has already created them.
- Any properties changed via the property grid in design time, are not
serialized by the code, even though the property values appear in Bold font
(indicating modification).
- If I close the form's designer, then reopen it, the changes made by the
end user are lost.

Any suggestions, or perhaps a link to a good ComponentModel tutorial would
be greatly appreciated.

Thanks, Dan I
 
C

Cristian Balcanu

Try add attribute DesignerSerializationVisibilityAttribute as bellow
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]


Let me know if it works. ;)

Cristi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top