Forms question (.)

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
 
J

Jose Luis Manners

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
{
}
 

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