using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace LUserControl { public class TransparentBase : Form { /// <summary> /// 遮罩窗体 /// </summary> public FrmTransparent FrmTran; } }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LUserControl { public partial class FrmTransparent : Form { /// <summary> /// 显示窗体 /// </summary> public TransparentBase frm; /// <summary> /// 主窗体 /// </summary> public Form MainFrm; public FrmTransparent() { InitializeComponent(); TransparencyKey = Color.White; } private void LoadData() { frm.FrmTran = this; frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(); } private void FrmTransparent_Load(object sender, EventArgs e) { LoadData(); } } }
用法:
FrmNoClose frmNoClose = new FrmNoClose(); //equipmentLstForm.smallCabinetCode = cd.Name; //equipmentLstForm.totalNum = cd.SavedNum; //equipmentLstForm.storedNum = cd.SavingNum; frmNoClose.Cabinet = cd; //frmNoClose.ShowDialog(); FrmTransparent frmTransparent = new FrmTransparent(); frmTransparent.frm = frmNoClose; frmTransparent.MainFrm = this; frmTransparent.ShowDialog();
FrmNoClose必须继承TransparentBase类