Mike at Bookup
Mike at Bookup

Reputation: 1314

How to repaint TGrid when values have changed

I have a TGrid with 5 columns and 5,000 rows.

The first 14 rows are visible. The TGrid.OnGetValue() method is working correctly to show the values of all 5 columns and the 14 visible rows.

Now the values have changed. How do I get the TGrid's visible rows and columns to display the new values?

(Scrolling down and then back up causes those 14 rows to display their new values as expected.)

I've tried these lines, which do not work…

  fListGrid.Repaint;
  fListGrid.InvalidateRect(TRectF.Create(0,0, fListGrid.Width, fListGrid.Height));
  fColumnOne.Repaint; // a column owned by the fListGrid
  fColumnTwo.Repaint; // a column owned by the fListGrid

After posting this, I did find one hack that worked. I set the RowCount to zero and restored it. It's not likely that the user will be able to interact with the grid in the tiny amount of time it is set to zero, but that's the price of a hack.

theRowCount := fListGrid.RowCount;
fListGrid.RowCount := 0;
fListGrid.RowCount := theRowCount;

Upvotes: 0

Views: 24

Answers (0)

Related Questions