Library Vcl NextSuite 6 NextDBGrid6 Articles Introduction


Both NextDBGrid and NextGrid are derived from same ancestor class (TNxCustomGrid6), and share most of the methods and properties. Working with columns, views and design-time editors is same in both component.

NextDBGrid is extended with data-aware features such as connection to TDataSet (DataSource property), FieldName property for each Column and other.


Associating Field with a column

NextDBGrid unlike NextGrid doesn't store data within own memory structure. Instead, it load data fields directly from DataSet (via TDataSource component), and display it in column-type presentation. Each Column within NextDBGrid can represent one TField, and on column type depends how this field will be drawn (as text, progress bar, checkbox...).

Which Field will be used by Column is specified by DataBindings.FieldName property of Column:

Data binding

After the DataSet is activated, TField object with specified FieldName is referenced to Field property.

Beside FieldName DataBinding property contain other properties required for interaction with associated field. For example, NullText property can be set to specify value to be painted when field is NULL.

If needed, FieldName property can be leaved unset, and value for cells inside this column can be obtained "virtually" via OnGetValue event.

Iterating trough records

When drawing is about to start, NextDBGrid set ActiveRecord to the first visible record on screen, and then draw each cell in this row. After ActiveRow is set, Field property of DataSet or column can be used.

After 1st row is drawn ActiveRecord is moved down to the next record, and Field objects are re-loaded with data from 2nd record and so on until last visible row (record) on screen is drawn. If grid is in non-buffered mode (as standard TDBGrid is), only records visible on screen are loaded to internal buffer. That way DB grids are efficient when loading thousands of records, or data from remote server.


Sign in