Back to Devexpress

TcxGridColumnEvent Type

vcl-cxgridtableview-c5ff7a64.md

latest4.2 KB
Original Source

TcxGridColumnEvent Type

The procedural type for column-related notification events.

Declaration

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

Parameters

NameTypeDescription
SenderTcxGridTableView

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.

delphi
uses
  dxCore; // 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;
cpp
#include "dxCore.hpp" // Declares soAscending, soDescending, and soNone values
// ...

void __fastcall TMyForm::cxGrid1DBTableView1ColumnHeaderClick(TcxGridTableView *Sender,
  TcxGridColumn *AColumn)
{
  UnicodeString AFieldName;
  // ...
  AFieldName = dynamic_cast<TcxGridDBColumn*>(AColumn)->DataBinding->FieldName;
  if(AColumn->SortOrder != soNone)
    Caption = "Data is sorted by " + AFieldName;
  else
    Caption = "Data is unsorted";
  if(AColumn->SortOrder == soAscending)
    Caption = Caption + " in ascending order";
  else if(AColumn->SortOrder == soDescending)
    Caption = Caption + " in descending order";
}

Direct TcxGridColumnEvent References

The following events reference the TcxGridColumnEvent procedural type:

TcxGridTableView.OnColumnHeaderClickAllows you to respond to a click on a column header.TcxGridTableView.OnColumnPosChangedOccurs when an end-user changes the visibility or position of a column within the current View.TcxGridTableView.OnColumnSizeChangedOccurs when a user changes the size of a column. See Also

TcxGridColumnCustomDrawHeaderEvent Procedural Type

TcxGridGetUnmergeableColumnsEvent Procedural Type

cxGridTableView Unit