Skip to main content

TcxGridColumnEvent Type

The procedural type for column-related notification events.

Declaration

TcxGridColumnEvent = procedure(Sender: TcxGridTableView; AColumn: TcxGridColumn) of object;

Parameters

Name Type Description
Sender TcxGridTableView

Provides access to the grid Table View that raised the column-related notification event.

You may need to cast the Sender parameter value to the corresponding terminal TcxGridTableView class descendant to access all public API members.

Tip

Call the Sender.ClassType function or use other RTTI functionality to identify the actual grid View type.

AColumn TcxGridColumn

Provides access to the grid column whose header was clicked.

The column type corresponds to the Sender grid View type. You may need to cast the AColumn parameter value to the corresponding terminal TcxGridColumn class descendant to access all public API members.

Tip

Call the AColumn.ClassType function or use other RTTI functionality to identify the actual grid column type.

Remarks

Column-related events notify the application of user interaction with columns, such as rearrangement and clicks on a header.

Code Example: Identify the Dataset Field Name of the Clicked Column

The code example in this section updates sorting information in the form caption every time a user clicks a column header in a bound grid Table View. The code example displays the name of the clicked column’s underlying dataset field.

uses
  dxCore;  // This unit declares soAscending, soDescending, and soNone values
// ...

procedure TMyForm.cxGrid1DBTableView1ColumnHeaderClick(Sender: TcxGridTableView;
  AColumn: TcxGridColumn);
var
  AFieldName: string;
begin
  AFieldName := (AColumn as TcxGridDBColumn).DataBinding.FieldName;
  if AColumn.SortOrder <> soNone then
    Caption := 'Data is sorted by ' + AFieldName;
  else
    Caption := 'Data is unsorted';
  if AColumn.SortOrder = soAscending then
     Caption := Caption + ' in ascending order'
  else if AColumn.SortOrder = soDescending then
     Caption := Caption + ' in descending order';
end;

Direct TcxGridColumnEvent References

The following events reference the TcxGridColumnEvent procedural type:

TcxGridTableView.OnColumnHeaderClick
Allows you to respond to a click on a column header.
TcxGridTableView.OnColumnPosChanged
Occurs when an end-user changes the visibility or position of a column within the current View.
TcxGridTableView.OnColumnSizeChanged
Occurs when a user changes the size of a column.
See Also