Forms question (.)

  • Thread starter Thread starter raffelm
  • Start date Start date
R

raffelm

I've created a custom control. And now I've done something that prevents
me from using the designer to layout controls on my custom control. I
tried deleting the .resx file, thinking the VS would just regenerate
it, but did not.

Here's how I got the problem:

I created a new user control. I called it BaseControl.

I created another new user control. I called it DerivedControl.
After VS generated the .cs file, I changed the base class to
BaseControl.

EG:
public class BaseControl : System.Windows.Forms.Control
public class DerivedControl : BaseControl

Now I am unable to add controls to DerivedControl using the designer.
I have to manually create the code in .cs file. This gets really hard
to lay things out.

So, what I can do so that I can use the designer?

Thnx
Matt
 
To be able to layout controls in your DerivedControl your BaseControl needs
to inherit from System.Windows.Forms.ContainerControl. Also, make sure that
you specify your Designer class for your DerivedControl which, like this:

[Designer(typeof(DerivedControlDesignerClassHere))]
[DesignTimeVisible(true), ToolboxItem(true)]
public class DerivedControl : BaseControl
{
}
 
Back
Top