المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : abstract, override and the Visual Studio Designer



C# Programming
02-17-2011, 03:11 AM
Hi all,

As a part of my project I have an abstract class that looks like this:
abstract class TabPageTemplate : TabPage
{
public abstract void Process();
public abstract void Cancel();
public abstract bool LoseFocus();
public abstract void Populate(int identifier);
public abstract event EventHandler PageClosed;
}I also have separate classes defined, all of which implement the above abstract class. On another Form (that contains a TabControl) I can then add any of these TabPages and know that each one will have implemented the four methods and one event handler so I can call any of them.

It works great, but there is one major inconvenience. I have to design the layout of all of those TabPages in code, I cannot use the VS Designer. The reason for this is that the Designer can't create an instance of whatever TabPage I'm busy designing (because the base class from which the TabPage inherits is abstract). This is the error message that the Designer gives me:
The designer must create an instance of type 'MyProject.TabPageTemplate' but it cannot because the type is declared as abstract.

Would anyone have some advice for me here? At first this wasn't a problem but these TabPages are getting quite complex now and doing all of the control layout in code is getting very tedious.