MessageBox实现自动延时关闭
2024-09-24 03:33:29
1,首先新建一个winform窗体:MessageForm,设置StartPosition属性为Manual,Location属性值-500, -500
主要是为了让MessageForm窗体不显示在页面上
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)
{ timer1.Interval = t;
timer1.Enabled = true;
MessageBox.Show(this, txt, "提示");
}
}
3,调用:
new MessageForm(, "输入参数有误").Show();
参考:https://blog.csdn.net/zheqingzheqing/article/details/51855274
最新文章
- 通过akRegionCode找到对应的程序
- HTML 网页特效CSS大全
- 一些NSArray,NSDictionary,NSSet相关的算法知识
- application
- 最小生成树Kruskal算法(邻接矩阵和邻接表)
- B. Om Nom and Dark Park
- 【LeetCode 208】Implement Trie (Prefix Tree)
- iphone开发第一个UI应用程序QQ
- JAVA与ABA问题
- spss
- 认识WinDbg
- Java基础——抽象类和接口
- 笔记:Eclipse 安装 Hibernate Tools
- 内置函数(sorted、map、enumerate、filter、reduce)
- Java四种引用--《深入理解Java虚拟机》学习笔记及个人理解(四)
- 虚拟机console基础环境配置——系统镜像站点配置
- ubuntu 12.04启用休眠
- 用CSS画基本图形
- web.xml启动spring详解
- UWP Button添加圆角阴影(二)