Inherited User Control not showing in designer

G

Guest

I have a user control that inherits from another user control. The base user
control works fine in the designer, I can see all of the controls, etc...

However when I open the derived control in the designer, all I see is a grey
square with no controls. I have tried attaching to the IDE with another
instance's debugger, but no exceptions are being thrown when the control is
open.

Here is how the constructors are setup:

Base Control:

public class MyBase : System.Windows.Forms.UserControl
{
[Browsable(false)]
protected AnotherObject _oObject;

[Browsable(false)]
public AnotherObject oObject
{
get{ return _oObject; }
set{ _oObject= value; }
}

public MyBase()
{
_oObject= new AnotherObject ();
}

public MyBase (AnotherObject oObject)
{
InitializeComponent();
_oObject= oObject;
}
}

Derived Control:

public class MyDerived: MyBase
{

public MyDerived(AnotherObject oObject) : base(oObject)
{
InitializeComponent();
}

public MyDerived() : base()
{
}

}


Please help!
 
G

Guest

I have finally figured this out, if anyone else is having this problem, the
key is to make sure that the call to InitializeComponent is made in the
default constructor. I added the default constructor to correct the problem
where the designer couldn't create an instance, but without that call, none
of the controls are created.

Duh.

Lee
 

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