双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

C# 怎么让Messagebox弹窗后,主窗口不能操作

lidaoying lidaoying 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的代码如下:软件一运行就开始定时执行Timer1_Elapsed内容,但是我发现定时执行弹窗对话框后,还能操作form1主窗口,我希望弹窗后不单击确定就不能操作主窗口,需要单击确认后再能操作主窗口

namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
System.Timers.Timer timer = new System.Timers.Timer();
timer.Enabled = true;
timer.Interval = 2000;//执行间隔时间,单位为毫秒
timer.Start();
timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer1_Elapsed);
}

private void Timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{

MessageBox.Show("停止操作!", " fail", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);


}
}
}
...全文

相关推荐

评论 23
收藏 已收藏
分享
返回顶部
lidaoying
C# 111,129 成员 642,540 内容