Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unsure What's Wrong Here
Message
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01400255
Message ID:
01400279
Views:
56
>I am trying to create a hierarchy of user controls.
>
>First I created an interface:
>
>
>public interface IPane
>{
>    int Top { get; set; }
>    int Left { get; set; }
>    int Height { get; set; }
>    int Width{ get; set; }
>
>    void Clear();
>    void Delete();
>    void New();
>    void SaveChanges();
>    void Setup();
>
>}
>
>
>Next I create an abstract user control that implements the interface:
>
>
>    public abstract class crlPaneBase : UserControl, IPane
>    {
>        public crlPaneBase()
>        {
>            Setup();
>        }
>
>        public abstract void Clear();
>        public abstract void Delete();
>        public abstract void New();
>        public abstract void SaveChanges();
>        public abstract void Setup();
>
>    }
>
>
>
>Finally, I created a user control and based it off the abstract class:
>
>
>public partial class crlShipItems : crlPaneBase
>{
>    public crlShipItems()
>    {
>        InitializeComponent();
>    }
>
>    public override void Clear()
>    {
>    }
>    public override void Delete()
>    {
>    }
>    public override void New()
>    {
>    }
>    public override void SaveChanges()
>    {
>    }
>    public override void Setup()
>    {
>    }
>}
>
>
>This compiles fine, but when I try to open crlShipItems in the designer I get:
>"The designer must create an instance of type 'InventoryTracker.crlPaneBase' but it cannot because the type
>is declared as abstract"
>
>I don't understand what the problem is here. How do I do this???

The designer will not work with classes derived from abstract base classes.
Here are a couple of workarounds (which I haven't tried):

http://www.codeproject.com/KB/dotnet/formsfromasbtractclasses.aspx
http://www.urbanpotato.net/default.aspx/document/2001

but it's probably best to avoid the issue altogether by not using an abstract root in the first place - just code the base class so that it will throw an exception if anyone tries to use it directly. Or just don't use the designer ;-{
Previous
Reply
Map
View

Click here to load this message in the networking platform