本文介绍了我正在用C#开发一个桌面应用程序....我想每5分钟自动刷新一次表格....所以我该怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am developing one desktop application in C#.... i want to auto refresh the form after every 5 minutes.... so how can i do this ?

推荐答案



public partial class Form1 : Form
    {
        Timer refreshTimer = new Timer();       // Create timer in code
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            refreshTimer.Interval = 300000;
            refreshTimer.Tick += new System.EventHandler(RefreshForm);
            refreshTimer.Enabled = true;
            refreshTimer.Start();
        }
        private void RefreshForm(object sender, EventArgs e)
        {
            // This code contains whatever you are using to refresh the data
            // Note the parameters are required to turn this function into a Tick handler
            this.textBox1.Text = "Refreshed";
        }
    }


这篇关于我正在用C#开发一个桌面应用程序....我想每5分钟自动刷新一次表格....所以我该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 23:28