abstract class 的Windoes Form窗体,不被IDE支持???

timiil timiil 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在写一个窗体的基类,实现一个 public abstract void DoSomething()的虚函数,(由于要求继承者必须重写这个虚函数,所以没有用virtual), 基类代码如下:

public abstract class frmFather : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;

public frmFather()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
if(components != null)
components.Dispose();
base.Dispose( disposing );
}

private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(544, 293);
this.Name = "frmFather";
this.Text = "frmFather";
this.ResumeLayout(false);
}

public abstract void DoSomething();
}

这个基类可以正常被继承了,子窗体也实现了必须实现DoSomething方法了,但现在的问题是当设计上述窗体的继承窗体时,设计器就一片花白。。。说不支持abstract 类型的窗体,创建不了实例。。。请问各位高手有好的解决办法没有?
...全文
评论 24
收藏 已收藏
分享
返回顶部
timiil
.NET Framework 17,748 成员 24,324 内容