Changes to FireMonkey Grid Controls in Berlin

From RAD Studio
Jump to: navigation, search

Go Up to What Was New in Berlin


In Berlin, the presentation logic and the data model of grid controls have been separated from the controls themselves. This separation makes it possible to support native presentations of grid controls.

As a result of this change, the API of grid controls (TCustomGrid and its subclasses, TGrid and TStringGrid) has changed. When you migrate an old project that uses grid controls to Berlin, you must take these API changes into account.

New Data Model

Grid controls have a new Model property that points to their data model, which is an instance of TGridModel or a subclass (e.g. TStringGrid uses TStringGridModel). Some of the properties of grid controls, such as Options, have moved to their data model, and only remain in grid controls as mirrors for their data model equivalents.

Two new options have also been implemented, TGridOption.AutoDisplacement and TGridOption.CancelEditingByDefault, to make it easier to edit grid cells on a mobile device with a virtual keyboard.

New Presentation Controls

The most noticeable change is the addition of a new unit, FMX.Grid.Style. Its TStyledGrid class implements the standard FireMonkey presentation for grid controls. You must include the new FMX.Grid.Style unit in one of the uses clauses of each of your old projects.

Note: This unit is automatically included in new projects.

You should not work with the presentation class directly but use the data model instead.

Other Grid Control Changes

In addition to the data model detachment and the presentation detachment, grid controls have undergone additional changes.

Some new API members have been added to grid controls: CellByPoint, CellRect, CanEdit, Col, DisplayCells, LeftColumn, RightColumn, Row, ScrollToSelectedCell, SetTopLeft.

TStringGrid has also gained properties for help context support: HelpContext, HelpKeyword, HelpType.

Grid controls are no longer responsible for their presentation. Because of that, OnApplyStyleLookup is only supported by TStringGrid and no grid control publishes the following events any more: OnCanFocus, OnClick, OnDblClick, OnDragEnter, OnDragLeave, OnDragOver, OnDragDrop, OnDragEnd, OnEnter, OnExit, OnKeyDown, OnKeyUp, OnMouseDown, OnMouseEnter, OnMouseLeave, OnMouseMove, OnMouseUp, OnMouseWheel, OnResize.

Note: These events are not published, but they are public, which means that you can use them at run time. However, you should use events from the grid model instead when possible.

Column Changes

Two new types of columns have been added:

Some existing column types have been improved:

TColumn has undergone some minor changes related to its behavior:

TColumn is no longer responsible for its presentation. Because of that, TColumn gained a Model property that points to the data model of its parent grid, and a PresentedControl property that points to the presentation control. However, many properties and events of TColumn have been replaced or are no longer supported as well: