Table header groups as cxgrid tables

I need to add a simple style to a Tableview based on a query in Delphi. I need it to look like this:

enter image description here

I know there is a way to group by fields, but I cannot figure out how to add 2 main header fields to the table header.

+3
source share
2 answers

This can be done using the BandedTableView. This view allows you to organize the columns into groups (in your case there will be two bands: Main title1 and Main title 2. NOTE: It is impossible to show a column without a group in this view. Thus, you will also have to create an additional strip for the Prim_Key column.

+6
source

I would do something like this

First clean the strips in the grid

for I := 0 to YourGrid.bands.count-1
YourGrid.bands[I].Free; 

Then you create title bars

CreateBands('Prime key Header',YourGrid);
CreateBands('Main Title 1 Header',YourGrid);
CreateBands('Main Title 2 Header',YourGrid);

Then you connect your columns to the group index

for I := 0 to YourGrid.ColumnCount - 1 do
begin
 if (YourGrid.Columns[I].Caption = 'prim_key') then
  YourGrid.Columns[I].Position.BandIndex := 0

end;
0
source

All Articles