自定义延时关闭弹窗,替代MesssageBox
2024-08-24 18:01:51
1,新建一个窗体MessageForm,在里面加一个label控件和timer
2,代码如下:
public partial class MessageForm : Form
{
int t;
string txt; /// <summary>
/// 自定义弹窗
/// </summary>
/// <param name="time">窗体消失时间</param>
/// <param name="text">窗体提示内容</param>
public MessageForm(int time, string text)
{
t = time;
txt = text;
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Close();
} private void MessageForm_Load(object sender, EventArgs e)
{
label1.Text = txt;
timer1.Interval = t;
timer1.Start();
}
}
3,在其他窗体调用:
MessageForm mf = new MessageForm(, "输入参数有误");
mf.Show();
最新文章
- java第四次作业
- (转)Linux NFS服务器的安装与配置
- android .apk安装时遇到NSTALL_FAILED_CONTAINER_ERROR错误
- cocos2d-x 3.0 版本 骨骼动画设置shader
- 细说.NET中的多线程 (三 使用Task)
- poj 2391 Ombrophobic Bovines(最大流+floyd+二分)
- freeswitch
- 如何获取并分析L2CAP包
- javascript获取以及设置光标位置
- How to tune SharePoint 2010 Server for better performance?
- 关于easyui模拟win2012桌面的一个例子系列
- ionic 最简单的路由形式,头部固定,下面tab切换-------一个简单的单页切换起飞了
- .net string类型集合转int集合
- Ubuntu16.04搭建OpenVPN
- FloatingActionButton(悬浮按钮)使用学习<;一>;
- Echarts动态加载柱状图和折线图混合展示的实例
- C#基础---------------C#正则表达式2
- H5保养
- JVM-类加载过程(Java类的生命周期)
- html中设置textbox的宽和高