all groups > dotnet windows forms designtime > august 2005 >
You're in the

dotnet windows forms designtime

group:

UserControl on inherited form


UserControl on inherited form Sebastian Bargmann
8/5/2005 11:39:50 AM
dotnet windows forms designtime:
Hi,

I'm having a mysterious problem in the designer. I have created a simple
usercontrol, which apparantly works fine except when placed on a inherited
form in the designer.

I drop the control on the form. Change one of the properties in the designer
(a color-setting in this case) and hit "build". The property then reverts to
its default value (defined in the constructor).

For some reason, when using an inherited form, the usercontrol's ctor is
called when I hit "build". But the designer fails to either save/load the
new value before/after doing so.

I'm guessing that I'm missing some vital attribute somewhere - relevant code
sections below:

<code>

public class Bevel : System.Windows.Forms.UserControl
{
private Color highlightColor;
[...]

public Bevel()
{
InitializeComponent();
highlightColor = SystemColors.ControlLightLight;
[...]
}

private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}

[Category("Appearance")]
[Description ("Highlight color")]
[DefaultValue(typeof(Color), "ControlLightLight")]
public Color HighlightColor
{
get
{
return highlightColor;
}
set
{
highlightColor = value;
Invalidate();
}
}
[...]
}

</code>


Any clues?

Thanks,
Sebastian

Re: UserControl on inherited form Allen Anderson
8/13/2005 12:57:32 PM
are you certian this only happens with an inherited form? have you tried a regular form to make sure it's not a problem with the serialization of the property? what is the type of the property?

[quoted text, click to view]
Re: UserControl on inherited form Sebastian Bargmann
8/16/2005 7:55:40 AM
Hi Allen,

[quoted text, click to view]

Yes, I only happens when dealing with inherited forms. The type of the
property is Color - but it happens with other types as well (enums at
least).

Thanks,
Sebatian

AddThis Social Bookmark Button