Badmiral
Badmiral

Reputation: 1589

windows form keeping datagridview up to date

I have a datagridview that is connected to a table. The datagridview changes when certain actions are made, but I would like it to refresh (i.e. reload the grid from a datatable that I create) even if the user isn't doing anything so the data the user sees is up to date. What is the best way to do this? Thanks!

Upvotes: 1

Views: 529

Answers (1)

General Grey
General Grey

Reputation: 3688

Try using a timer like this

private void Form1_Load(object sender, EventArgs e)
    {
        Timer timer = new Timer();
        timer.Interval=1000; // time in milliseconds
        timer.Tick+=new EventHandler(timer_Tick);
    }

    void timer_Tick(object sender, EventArgs e)
    {
       //Do your update here
    }

Upvotes: 1

Related Questions