The TIBDynamicGrid is illustrated above using Firebird's example “employee” databases.

In use, it looks just like a TDBGrid and is a TDBGrid descendent. Any project that uses IBX and TDBGrid can thus be quickly converted to using TIBDynamicGrid. The control uses SQL Manipulation to manage column sorting.

The above example can be found in “ibx/examples/employee” and illustrates most of the benefits of TIBDynamicGrid.

  • Resize the form and you will see how the “Dept” column automatically grows/shrinks to ensure that the grid always fills the available space and how the Salary “Total” control (TDBText) moves so that it is always aligned with the grid. Column resizing is controlled at design time by setting the AutoSizeColumn property for each column that it is to be dynamically resized, with its design time width interpreted as the minimum column width. All other column widths remain unchanged.

  • Click on the “Started” column header (or any other column header) and the table will be resorted by that column. A second click on the same header reverses the sort order.

  • Select a row and press “F2”, click on “Edit” or the left hand indicator column and the Editor Panel is revealed (See Illustration 2). This allows the row to be edited free of the constraints imposed by a simple column editor.

  • After reopening the dataset (e.g. after a re-sort or change of filters) the previously selected row is automatically reselected.

  • The filters, such a “salary range”, also illustrate how the new IB SQL Parser works with the TIBDynamicGrid. For example, where a salary range is selected, the dataset is re-opened and the filters are applied in the BeforeOpen event handler.

  • Each row can still be edited without having to open the panel editor. The column “located” is an example of the use of TIBLookupComboEditBox as a column editor. Note that the country list is dynamically generated and varies according to Job Code (an Employee Database constraint).


Column Properties

Most of TIBDynamicGrid's new features are accessed via the column editor and are properties of each column in the grid. The new column properties are given below.



If true then the column is automatically resized to fill the grid. More than one column can have this property set to true.



Optional. Used to identity a control (typically a TDBEdit or TDBText) to be kept in vertical alignment with the column, and to have the same width. Note that the horizontal positioning is unaffected by grid resize, and hence the total can be placed either above or below the grid.



Identifies the column used to sort the grid when the dataset is first opened.



These properties are copied to a TIBLookupComboBox when it is used as a column editor. Setting TDBLookupProperties.ListSource implictly requests this as the column editor instead of a normal pick list.

If the TDBLookupProperties.DataFieldName is not set then the control works as a “pick list” with its values taken from the List Source DataSet.

If the TDBLookupProperties.DataFieldName is set then it works as full lookup list. The DataFieldName identifies a field in the parent TIBDynamicGrid.DataSource.DataSet. This field does not have to be visible in the grid. When the editor completes, the identified field is set to the value of the List Source field identified by TDBLookupProperties.KeyField.

TIBDynamicGrid New Properties



When set, this control (typically a TPanel or TFrame) is used as the Editor Panel (see below).



When set and an editor panel is displayed, the row height is set to the current row height plus the panel height and the Editor Panel placed under the row. That is, the original row is still displayed with the editor panel beneath it. The default is that the editor panel appears to replace the row.



Enables column sorting by column header click (default true).



Determines the initial sort order. Default is false i.e. ascending sort order.



Determines the initially selected row when the dataset is first opened. If true then the last row is selected, otherwise the first row. Default: false.



This is a semi-colon separated list of one or more dataset fieldnames. Typically this is the primary key for the dataset. Used for automatic reselection of rows after the dataset is reopened.

A property editor is available for design time field name selection.

TIBDynamicGrid new Events


This event is called before the Editor Panel is hidden. Can be used to validate changes.


This event is called after the Editor Panel is made visible


This event is called after the Editor Panel is hidden. Can be used to do any additional tidying up needed.


The TIBDynamicGrid uses a KeyDown handler to intercept edit keys while the Editor Panel is active. For example, to process an “escape” key as a cancel edit. You can write your own keydown handler to modify this behaviour.


Called when a column header is clicked and before the dataset is re-sorted. Can be used to modify the column index for the sort.


Called when the dataset select SQL is being modified prior to resorting the dataset. Can be used to modified the SQL “Order by” clause. e.g. to add a subsort column. For example, useful when one column has a “year” and the next column is the “month”. Clicking on “year” can then made to subsort on “month”.

The Editor Panel

An Editor Panel may be any TControl available on the form. However, in practice, it is typically either a TPanel or a Tframe. The example shows a TPanel being used as an Editor Panel.

You can create an Editor Panel by simply dropping it on to the same form as the TIBDynamicGrid and then selecting it as the value of the TIBDynamicGrid.EditorPanel property.

To be useful, the Editor Panel should be populated with data aware controls that use the same DataSource as the grid and are individually used to edit fields in the same row. The height of the panel should be the minimum necessary as this will determine the row height when it is visible.

At run time, the Editor Panel is automatically hidden until called into use by either:

  1. Pressing “F2” when the Dynamic Grid has the focus.

  2. Clicking on the left hand indicator column, or

  3. Calling the TIBDynamicGrid.ShowEditorPanel method.

In order to show the editor panel, the following actions are performed by the TIBDynamicGrid:

  • The current row is resized to the height of the Editor Panel.

  • The Editor Panel is resized and repositioned so that it fits exactly over the current row.

  • The Editor Panel is made visible.

The current row can now be edited using the child controls on the Editor Panel – that is as long as their DataSource is the same as the grid's.

The Editor Panel is hidden (and any changes Posted to the DataSet) when:

  1. A different row is selected by the mouse or up/down arrow keys

  2. The Escape Key is Pressed (cancels the changes)

  3. “F2” is pressed.

  4. The TIBDynamicGrid.HideEditorPanel method is called.

Once the Editor Panel is hiddent, the current row is re-sized back to its correct height.