I have a windows form which has to be refreshed automatically without using any button to refresh the form.
Right now am using a button to refresh the form. But I need the form to refresh automatically for every 1 minute.
It is possible to do in windows form application.
I'm not sure why you need to refresh a form, but put whatever code you have behind the button in a timer event. You already have the code, so just create a timer, set it for the length you want, and turn it on.
Here is the code you need:
Timer myTimer = new Timer();
myTimer.Elapsed += new ElapsedEventHandler( TimeUp );
myTimer.Interval = 1000;
myTimer.Start();
public static void TimeUp( object source, ElapsedEventArgs e )
{
//Your code here
}
You can add a Timer to the form and enable it on Form_Load. Set the timer value in milliseconds to 60000. In the Timer_Tick function, you can put the code meant for refreshing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With