给窗体做遮罩(另类做法)
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类
作者:三小
声明:原创博客请在转载时保留原文链接或者在文章开头加上本人博客地址,如发现错误,欢迎批评指正。凡是转载于本人的文章,不能设置打赏功能,如有特殊需求请与本人联系!