private void menuDishInfo_Click(object sender, EventArgs e) { FrmDishInfo Frmdi = FrmDishInfo.CreateFrm(); //实例 Frmdi.Show(); //显示 Frmdi.Focus(); //给焦点 }
} //保存实例 /// <summary> /// 单例模式中静态实例本类对象 /// </summary> /// <returns>实例的对象</returns> public static FrmDishInfo CreateFrm() { if (_FrmDishInfo == null) //判断是否已经实例对象 { _FrmDishInfo = new FrmDishInfo(); } return(_FrmDishInfo); //返回 }
private void FrmDishInfo_FormClosing(object sender, FormClosingEventArgs e) { _FrmDishInfo = null; //关闭窗口后释放实例资源 }