Sub OnBandBaseClick(Sender: Object; Args: IDataGridBandEventArgs);
Begin
//set of operators;
End Sub OnBandBaseClick;
Sender. The parameter that returns the component that generated the event.
Args. The parameter that determines event parameters.
The OnBandBaseClick event occurs after clicking on the column or band header.
After clicking on the column header or band, the following occurs:
The OnBandBaseClick event occurs.
The column is sorted.
The DataGrid.OnSort event occurs.
Executing the example requires a form and the DataGrid component with the DataGrid1 identifier on the form.
The handlers must be assigned for the following events:
For the OnBandBaseClick event - the DataGrid1OnBandBaseClick handler.
For the DataGrid.OnSort event - the DataGrid1OnSort handler.
For the Form.OnShow event - the DATAGRID_ONBANDBASECLICKFormOnShow handler.
Add a link to the MathFin system assembly.
Class DATAGRID_ONBANDBASECLICKForm: Form
DataGrid1: DataGrid;
Rows: IDataGridRows;
Arr: Array Of String;
Sub DATAGRID_ONBANDBASECLICKFormOnShow(Sender: Object; Args: IEventArgs);
Var
i: integer;
Begin
//Set number of table rows and columns
DataGrid1.AbsoluteRowCount := 5;
DataGrid1.ColumnCount := 2;
Arr := New String[DataGrid1.AbsoluteRowCount];
//Fill table with data
For i := 0 To DataGrid1.AbsoluteRowCount - 1 Do
DataGrid1.CellValue(i, 0) := i + Math.Power(10, DataGrid1.AbsoluteRowCount - 1 - i);
//Copy each row value
Arr[i] := DataGrid1.CellValue(i, 0);
End For;
End Sub DATAGRID_ONBANDBASECLICKFormOnShow;
Sub DataGrid1OnBandBaseClick(Sender: Object; Args: IDataGridBandEventArgs);
Var
i: integer;
Begin
//Copy value of each row of the first column
For i := 0 To DataGrid1.AbsoluteRowCount - 1 Do
Arr[i] := DataGrid1.CellValue(i, 0);
End For;
End Sub DataGrid1OnBandBaseClick;
Sub DataGrid1OnSort(Sender: Object; Args: IDataGridColumnEventArgs);
Var
i: integer;
Begin
//Fill the second column with data of the first column before sorting
For i := 0 To DataGrid1.AbsoluteRowCount - 1 Do
DataGrid1.CellValue(i, 1) := Arr[i];
End For;
End Sub DataGrid1OnSort;
End Class DATAGRID_ONBANDBASECLICKForm;
After executing the example, after clicking on the first column header the rows are sorted in ascending order of their values, and the first column values before sorting are written to the second column.
See also: