如何在C#中的特定时间间隔后自动刷新窗体 [英] How to refresh windows form automatically after specific time interval in C#

查看:667
本文介绍了如何在C#中的特定时间间隔后自动刷新窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了Windows窗体,我想更新该窗体数据而不关闭该窗体。应该从数据库中自动获取数据。

当前数据仅在表单加载时更新。我必须每次关闭表单以从数据库获取最新数据。

可以这样做吗?



我有什么试过:



当前数据仅在表单加载时刷新。我想要在没有表单加载的情况下刷新数据。

i have developed windows form and i want to update that form data without closing that form.means data should be automatically fetched from database.
currently data is updated on form load only.i have to close the form each time to get latest data from database.
it is possible to do this??

What I have tried:

currently data is refreshed on form load only. i want data to be refreshed without form load.

推荐答案

最简单的选择是使用 System.Windows.Forms.Timer 在此处查看示例:

计时器类(System.Windows.Forms) [ ^ ]

您可以在代码中定义Timer,或从工具箱中将一个拖到窗体上。

有关计时器的更多信息,请访问:计时器 [ ^ ]
The easiest option is to use a System.Windows.Forms.Timer see example here:
Timer Class (System.Windows.Forms)[^]
You can define the Timer in code, or drag one from the Toolbox onto your form.
More information on Timers here: Timers[^]


这篇关于如何在C#中的特定时间间隔后自动刷新窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆