我在Windows窗体中遇到了继承控件的问题,需要一些建议.
我确实为List中的项目(由面板构成的自制GUI列表)和一些可以添加到列表中的每种数据类型的继承控件使用基类.
它没有问题,但我现在发现,将基本控件变成抽象类是正确的,因为它有方法,需要在所有继承的控件中实现,从内部的代码调用base-control,但不能也不能在基类中实现.
当我将基本控件标记为抽象时,Visual Studio 2008 Designer拒绝加载窗口.
有没有办法让Designer使用基础控件制作抽象?
我有一个winforms项目,我在程序集A上创建了一个类,它继承自System.Windows.Forms.Form作为我项目中各种表单的基类,基类类似于:
public partial class DataForm<T> : Form where T : class
{
    T currentRecord;
    protected T CurrentRecord
    {
        get
        {
            return currentRecord;
        }
        set
        {
            currentRecord = value;
            CurrentRecordChanged();
        }
    }
}
现在,当我在程序集B上创建一个继承自我的DataForm的表单时,设计器将无法加载,但如果我编译它,应用程序运行正常.
表格如下:
public partial class SomeTableWindow : DataForm<SomeTable>
{
    public SomeTableWindow ()
    {
        InitializeComponent();
    }
}
我得到的错误是:
The designer could not be shown for this file because none of the classes within it can be designed. 
The designer inspected the following classes …