DataGridview update

  • Thread starter alexander.stuckenholz
  • Start date
A

alexander.stuckenholz

Hi folks,

I have a datagridview with custom update-method where I access the
this.Rows property directly. I have no bindingsources, datatsets or
anything (and it would cost me a lot of work to change this).

Now I would like to update the datagridview by a background-thread.
How can I do that. The BeginInvoke-way seems not to work, as the
control is not updated.

Best regards,

Alex
 
M

Marc Gravell

The BeginInvoke-way seems not to work, as the
control is not updated.

If you mean Control.BeginInvoke (not Delegate.BeginInvoke), then it
should work fine do... have you got any short code that demonstrates
this?

One issue is that it just might not update *yet* unless you use
Invoke; this of course means that you have to be very careful about
where you store the data you want to push into the grid (i.e. the
following pseudo# is bad)

string newValue;
for each row
{
newValue = someCalc();
this.BeginInvoke((MethodInvoker) delegate { theCell.Value =
newValue;});
}

The problem (above) is that there is no guarantee which version of
newValue went into each cell. It is less troublesome (and arguably
more performant) to call Invoke. but passing multiple values (rows/
etc) than lots of calls to Invoke/BeginInvoke.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top