MDI-继承窗口如何做到只能实例化一个了窗口
基窗口:
public partial class BaseForm : Form
{
private static BaseForm instance=null;
public BaseForm()
{
InitializeComponent();
}
public static BaseForm Instance ( Form fm1 ) {
if (instance == null)
{
instance = new BaseForm ( );
instance.MdiParent = fm1;
instance.Show ( );
return instance;
}
else
{
instance.BringToFront ( );
instance.WindowState = FormWindowState.Normal;
return null;
}
}
}
调用:BaseForm childFM1=BaseForm.Instance(this);
继承窗口:
public partial class Form1 : MRP.UI.BaseForm
{
public Form1()
{
InitializeComponent();
}
}
调用:
Form1 Form1=Form1.Instance(this);
错误 1 无法将类型“MRP.UI.BaseForm”隐式转换为“MRP.UI.Form1”。存在一个显式转换(是否缺少强制转换?)
怎么更改才能实现目的,请各位指点一下,谢谢了!
------解决方案--------------------public static BaseForm Instance ( Form fm1 ,Type FormType ) {
if (instance == null)
{