作者:坚强萝卜_854 | 来源:互联网 | 2023-10-10 15:34
1,首先新建一个winform窗体:MessageForm,设置StartPosition属性为Manual,Location属性值-500,-500主要是为了让MessageFo
1,首先新建一个winform窗体:MessageForm,设置StartPosition属性为Manual,Location属性值-500, -500
主要是为了让MessageForm窗体不显示在页面上
2,窗体内代码如下:
public partial class MessageForm : Form
{
int t;
string txt;
///
/// 自定义弹窗
///
/// 窗体消失时间
/// 窗体提示内容
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(3000, "输入参数有误").Show();
根据https://blog.csdn.net/zheqingzheqing/article/details/51855274简单修改