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!

RE: Inherited User Control not showing in designer by Lee

Lee
Tue Dec 28 00:05:02 CST 2004

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

"Lee" wrote:

> 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!