Everything looks almost perfect, now i need a bit help with some math.
I have 992 tiles, tiles are all 64x64 pixels, and lets say i have grid on form which has 12 columns and 8 rows visible.

12 * 8 = 96 tiles are currently visible.

How can i calculate how many columns (and rows) are needed for the rest of the tiles?
I mean calculate the needed rows / columns for all of the tiles by also counting in current col- and rowcount?

Whats the proper math?

I tried something like:
Code:
kgrid1.ColCount:=992 div kgrid1.rowCount;
But it doesnt work very well. Last tiles are not drawn sometimes and sometimes they are.

Column count can change and same with row count. Because user can resize grid (actually the form).


Thanks for any tip.