I am working on a project in C# at the moment which is quite simple.
I have a status box, two buttons and a dataGridView.
When the Form loads the dataGridView is filled correctly.
What I would like to do is then update that table every 45 seconds to reflect any changes in the database.
I am looking for suggestions on a technique to achieve this. I have been searching for clear information but it seems somewhat lacking.
Timer
control to your form. (It's in the components category)Interval
property to 45000
(the value represents milliseconds)Enabled
property of the timer to True
in the form designer, or somewhere in your code.Tick
event (you can get this by double-clicking the timer)Tick
handler, update your dataGridView
Your handler will look like this:
private void timer1_Tick(object sender, EventArgs e)
{
// Update DataGridView
}
If you need to suspend updates for some reason, you can call timer1.Stop()
to stop the timer from running, and use timer1.Start()
to start it up again.
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