您当前的位置: 首页 >  c#

顺其自然~

暂无认证

  • 1浏览

    0关注

    1317博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C#窗体最前终极解决方案

顺其自然~ 发布时间:2020-09-15 15:05:10 ,浏览量:1

1、新建一个窗体程序,添加一个Timer控件以及设置它可用并绑定事件。

2、设置窗体的TopMost属性为True

3、然后设置代码如下即可实现

using System;
using System.Windows.Forms;
using Socket.Common.Entity;
using System.Runtime.InteropServices;
using BizReview.Win32;

namespace Test.Tip
{
    public partial class Form1 : Form
    {
        private int i = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void timer1_Tick(object sender, EventArgs e)
        {            
            this.TopMost = false;
            this.BringToFront();            
            this.TopMost = true;
            if (i>5)
            {
                timer1.Enabled = false;
            }
            i++;
        }
    }
}

 

关注
打赏
1662339380
查看更多评论
立即登录/注册

微信扫码登录

0.0394s