Designer Generated Code

K

Kemo

Hi,

I derived a form (System.Windows.Forms.Form), which has a "BorderPen"
property of type "System.Drawing.Pen". All other forms in my Application are
derived from this one. I have a PenEditorControl, to edit this property
directly in PropertyGrid at the design time, but the problem is - no code is
generated for my property in "<formClassName>.Designer.cs" to set the value.
So I can see the Border in the Designer, as soon as I change the property
value, but because there was no code generated, the border is still
unchanged in the application. And in designer the information will be lost
after reinitiating the designer (or after rebuilding the project).
I was browsing MSDN over 2 hours, and I have several ideas, but I would
highly appriciate if someone could give me an advice.

Thank you!!!
 
J

Jeff Johnson

I derived a form (System.Windows.Forms.Form), which has a "BorderPen"
property of type "System.Drawing.Pen". All other forms in my Application
are derived from this one. I have a PenEditorControl, to edit this
property directly in PropertyGrid at the design time, but the problem is -
no code is generated for my property in "<formClassName>.Designer.cs" to
set the value. So I can see the Border in the Designer, as soon as I
change the property value, but because there was no code generated, the
border is still unchanged in the application. And in designer the
information will be lost after reinitiating the designer (or after
rebuilding the project).
I was browsing MSDN over 2 hours, and I have several ideas, but I would
highly appriciate if someone could give me an advice.

I assume you've already looked at this, but I have to ask anyway: Have you
set the DesignerSerializationAttribute for this property?
 
K

Kemo

The attribute I used is called "DesignerSerializationVisibility" (may be
the Attribute name varies in the different version of .NET, I am using .NET
3.5). I tried several combinations and had no success. I was thinking, may
be I should derive a class from
"System.ComponentModel.Design.Serialization.CodeDomSerializer" and implement
it for the Pen? I wonder if this is the correct solution :/
Bellow is the declaration of the property with attributes.

[RefreshProperties(RefreshProperties.Repaint)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Localizable(true)]
[Editor(typeof(PenEditor), typeof(UITypeEditor))]
[DefaultValue(null)]
public Pen BorderPen { get; set; }

Thank you, Jeff

----- Original Message -----
From: "Jeff Johnson" <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Friday, January 30, 2009 7:39 PM
Subject: Re: Designer Generated Code
 

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