Sergey Moshkov
Sergey Moshkov

Reputation: 491

Control are not loaded in designer in C#

A very simple example. I have two classes:

public class BaseControl : UserControl  {  }

public partial class MyControl : BaseControl 
{
    public MyControl()
    {
        InitializeComponent();
    } 
}

I can open BaseControl in designer mode, but MyControl can not (VS 2008). I CAN NOT just inherit class MyControl from class UserControl. Is there any way to solve this problem?

Upvotes: 1

Views: 424

Answers (2)

Kirill Bestemyanov
Kirill Bestemyanov

Reputation: 11964

You need to decorate your class MyControl with the [Designer(typeof(MyControlDesigner))] attribute

and write MyControlDesigner class that inherited IDesigner

Upvotes: 0

Furqan Safdar
Furqan Safdar

Reputation: 16698

Make sure you have classes defined this way:

public class BaseControl : UserControl  
{  
    public BaseControl()
    {
        InitializeComponent();
    } 
}

public partial class MyControl : BaseControl 
{
    public MyControl()
    {
        InitializeComponent();
    } 
}

Upvotes: 1

Related Questions