TDBAdvGrid autosize

What is correct procedure for autosizing columns of TDBAdvGrid with PageMode = true ? I have tried two options:

1. After loading grid with data I call AutoSizeColumns(true, 6). The disadvantage of this solution is that only rows on first page are autosized. When I scroll data and there are long texts, column is too narrow for them. I must click into that cell to resize appropriate column (the properties DirectEdit and SizeWhileTyping are enabled).

2. Setting property AutoSize to true. It does nothing contrary to its name.

If you set grid.PageMode = true, the sizing of columns is based on the visible records only. This is normal & by design as in this mode, only the visible records are loaded in the grid.
If you set grid.PageMode = false, all records are loaded in the grid and the grid can perform an autosize on all records in the grid.

I understand but what shall I do to correctly resize columns as needed ? I cant switch to PageMode = false only because autoresizing doesnt function. I use PageMode because of speed and because changed values are directly stored to database without interaction with application code. This has priority in my case.

Your request is contradictory. When PageMode = true, the grid has only visible records which is what makes it fast. As a result, it can only calculate the width based on the records it has. You indicate you want in this mode a column width calculation for ALL records (and still have a fast solution) but clearly, for calculating the size of ALL records, the grids needs to get ALL records and in case of a large database, that of course takes more time than just calculating for the visible records.

No, this is not my requirement. My requirement is that each time the user drags the scrollbar, the width of columns changes appropriately to see all content in cells. Changing width column too often can be visually disturbing so it would be good to change column width only if it is too narrow. If it is too wide it is not a problem. Currently I dont see any event in which I could call AutoSizeColumns method. Even when this event would exists it is not ideal solution because we would redraw grid in two steps which could result in flickering.

You could add AutoSizeColumnsto the OnScroll event of the dataset?

Proposed solution functions correctly, but the redrawing is too slow. The scrolling slows down to a crawl.

Obviously computing width of all columns based only on visible rows is too slow for smooth function of a control. It would be sufficient to consider only row that was not visible and after scroll it is visible.

Its not a big problem because when I click into cell with long text, the columns is autoresized (as said in first post). I can live with it. But it would be more user-friendly to have some fast autosize mechanism for page mode.