我声明了以下Generic usercontrol:
public partial class MessageBase: UserControl { protected T myEntry; public MessageBase() { InitializeComponent(); } public MessageBase(T newEntry) { InitializeComponent(); myEntry = newEntry; } } }
但编译器不允许我这样做:
public partial class MessageControl : MessageBase{ public MessageControl() { InitializeComponent(); } }
如何在C#中创建通用用户控件?
试试这个
public partial class MessageControl : MessageControlBase { public MessageControl() { InitializeComponent(); } } public class MessageControlBase : MessageBase{}
让设计人员工作的关键是你正在编辑的类的基类不能是通用的.