UserControl on inherited form

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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


.



Relevant Pages

  • UserControl on inherited form
    ... I'm having a mysterious problem in the designer. ... highlightColor = SystemColors.ControlLightLight; ... private void InitializeComponent() ... public Color HighlightColor ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: UserControl on inherited form
    ... >I'm having a mysterious problem in the designer. ... >For some reason, when using an inherited form, the usercontrol's ctor is ... > highlightColor = SystemColors.ControlLightLight; ... > private void InitializeComponent() ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Trouble with radio button list in Asp.net 1.1
    ... private void Page_Load ... /// Required method for Designer support - do not modify /// the contents of this method with the code editor. ... private void InitializeComponent() {this.Button1.Click += new System.EventHandler; ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Please thiHelp
    ... > * Required designer variable. ... > protected void Dispose(boolean disposing) ... > * the contents of this method with the code editor. ... > private void InitializeComponent() ...
    (microsoft.public.dotnet.vjsharp)
  • Re: Please thiHelp
    ... > * Required designer variable. ... > protected void Dispose(boolean disposing) ... > * the contents of this method with the code editor. ... > private void InitializeComponent() ...
    (microsoft.public.dotnet.vjsharp)