Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Refreshing a DataGridView On a Timer

$
0
0

I have a DataGridView I would like to refresh every x amount of seconds. I can refresh easy enough using a button_click:

private void CmdRefesh_Click(object sender, EventArgs e)
{
            pMF_ToolingRequestsTableAdapter.Fill(this.activeRequestsDataSet.PMF_ToolingRequests);

             DgvRequests.Parent.Refresh();
}

but when I call it from a system.timers.timer (in a cross-thread call), it doesn't refresh the UI at all by adding any additional rows. Heres what I'm using:

private void OnTimedEvent(object sender, ElapsedEventArgs e)
{
            pMF_ToolingRequestsTableAdapter.Fill(this.activeRequestsDataSet.PMF_ToolingRequests);

               BeginInvoke(new MethodInvoker(delegate{ DgvRequests.Update(); }));
               BeginInvoke(new MethodInvoker(delegate { DgvRequests.Parent.Refresh(); }));
}

why doesn't it add rows to the UI?



Viewing all articles
Browse latest Browse all 2535

Trending Articles