Skip to main content

Grid Control

  • 4 minutes to read

The public API of the DevExpress VCL Data Grid (TcxGrid) control is organized differently compared to the standard VCL TDBGrid control. When you place the TcxGrid control on a form and browse control properties in the Object Inspector, you will not find any properties that allow you to bind the control to a data source, customize columns, or change other data binding and layout settings, unlike TDBGrid. This topic explains the difference between the DevExpress and standard VCL grid controls and where to find data-related APIs.

Basic Grid Control Setup

The image below illustrates a TcxGrid control when you add it from the Tool Palette to a form.

Default Level/View Structure

The Structure Navigator at the control’s bottom-right corner displays three labels that indicate the following elements:

cxGrid1
The grid control.
cxGrid1Level1
An automatically created Level.
cxGrid1DBTableView1
An automatically created data-aware Table View associated with the Level.

Use the grid View’s settings to bind the View to a data source and specify how to visualize its data. To display the grid View’s settings in the Object Inspector, click the View’s label in the Structure Navigator.

DataSource Property in the Object Inspector

Refer to the following topic for details on how to manage grid Levels, specify associated grid Views, and customize Level and View settings: Grid Levels.

Grid Architecture Details

TcxGrid is a multi-purpose control that can display data in multiple formats and layouts that differ significantly, such as tables, cards, charts, and others. Moreover, the control can display data in master-detail relationship from multiple independent data sources. Data for each detail or data source can also have its own display format. To implement such versatility, the TcxGrid control requires two key concepts – grid Views and Levels. Each grid View type implements a specific data format/display layout and includes the following features:

  • An individual data binding mechanism
  • An ability to process and shape data in a specific manner with individual customization settings
  • A common API for uniform management

Grid Levels arrange grid Views into hierarchical and multi-branch structures. The grid control maintains a hierarchy of grid Levels, and each grid Level has an associated grid View that visualizes data. So the grid control is a container for grid Views, which actually display the data.

Grid Control Settings

Grid Views contain all data binding and layout settings, while the TcxGrid control has settings common to its elements and settings for the root grid Level. The following sections include a brief overview of the grid control settings.

Settings Inherited from TcxControl

Since TcxGrid is a descendant of the TcxControl class, the grid control includes most of the settings common to all visual controls. These settings allow you to specify the grid control’s size, position, tab order, and other attributes.

TcxGrid Class Inheritance

Look & Feel Customization

The grid control has look & feel settings common to all DevExpress VCL controls. The grid control’s LookAndFeel property allows you to access look & feel settings. You can either customize them directly or add a TcxLookAndFeelController or TdxSkinController component to a form to change look & feel settings for all UI elements in an application simultaneously.

Level Management

The grid control’s Levels property provides access to the root Level of the grid Level hierarchy that the control maintains. The root Level stores a collection of child Levels and determines their appearance. To customize the appearance settings, use the control’s RootLevelOptions and RootLevelStyles properties. The control maps these properties to the root Level’s Options and Styles properties as shown below:

Level Management Settings

The grid control’s ActiveLevel property allows you to activate any grid Level in this collection and display the associated grid View to a user.

Level Tab Customization

A grid Level has an option to display a tab. A user can click it to activate the grid Level and its View. Use the grid control’s LevelTabs property to customize the tab appearance. You can handle the grid control’s OnActiveTabChanged event to respond to tab clicks.

View Management

Since the TcxGrid control can display multiple grid Views simultaneously, it includes a number of API members that allow you to manage the Views. For instance, the Views property provides access to all pattern grid Views created in the control, while the CreateView function allows you to add more Views.

Use the FocusedView property to access the focused grid View or move focus between Views. Users can utilize the mouse or keyboard to move focus between grid Views. You can handle the OnFocusedViewChanged event to track the focus movement.

See Also