0

Im currrently working on an iPad application which uses a TGrid with dynamic created content.

But it gives me some problems: For some reason, i cant free and release objects added to the TGrid (Removing them again). In Windows, FreeAndNil solves it, but apperently FreeAndNil does nothing in Mac Simulator or on an iPad device. The only solution i could come up with would be to set RowCount to the appropriate amount, but the controls are still present and this overwritten.

Also is it possible to disable horizontal scrolling in a TGrid somehow or would i need to implement a custom control for that?

  • 2
    [`DisposeOf`](http://docwiki.embarcadero.com/Libraries/en/System.TObject.DisposeOf) frees an object on mobile platforms. – LU RD Jul 08 '14 at 09:08

2 Answers2

1

On mobile platforms with ARC, Free/FreeAndNil does not immediately free an object. See The Free and DisposeOf methods under ARC.

Instead use DisposeOf(), which immediately will call the destructor.

DisposeOf forces the execution of the destructor code in an object. The new Delphi mobile compilers introduce a new dispose pattern implemented by calling DisposeOf, which executes the destructor code even if there are variables with pending references to the object. After the DisposeOf method is called, the object is placed in a special state, the Disposed state. This means that the destructor is not called again if DisposeOf is called again, or if the reference count reaches zero (the moment in which the memory is released).

LU RD
  • 34,438
  • 5
  • 88
  • 296
0

Also is it possible to disable horizontal scrolling in a TGrid somehow...

Of course, just resize your columns to fit the size of the grid. Or, if you cannot do this, play with the TColumn.Visible property. If sum of visible columns' witdh is less than grid's width you'll have no scroller. But w/o scroller you must deal with walking left and right through the grid.

Example: grid with 5 columns, only first 2 visible and buttons for left and right. when right button is pushed, leftmost visible column 0 goes invisible and column 2 starts to be visible /now columns 1 and 2 are visible/.

LHristov
  • 1,103
  • 7
  • 16
  • For some reason, i cant get this to work. I try set the only column to the same length of TGrid, with no other options set and even if the horizontal scroll isnt visible, i can still "move" the column positions (also visually it looks as if the column and rows are not fully attached, but move left or right). Perhaps the issue is not attached to scrolling? – Ronni Simonsen Jul 09 '14 at 08:04
  • You said nothing about vertical scrollbar and if you have vert scroll bar you must reduce your column. Look here: http://stackoverflow.com/questions/1716870/how-to-find-the-actual-width-of-grid-component-with-scrollbar-in-delphi – LHristov Jul 09 '14 at 10:59