I need to add a simple style to a Tableview based on a query in Delphi. I need it to look like this:
I know there's a way to group by fields, but I can't seem to figure out how to add the 2 main title fields to the header of the table.
I need to add a simple style to a Tableview based on a query in Delphi. I need it to look like this:
I know there's a way to group by fields, but I can't seem to figure out how to add the 2 main title fields to the header of the table.
This can be done using the BandedTableView. This view allows you to arrange columns by Bands (in your case, there will be two bands: Main title1 and Main title 2. NOTE, that it is impossible to show a column without a band in this view. So, you will also have to create an additional band for the Prim_Key column.
I would do something like this
First Clear the bands in your grid
for I := 0 to YourGrid.bands.count-1
YourGrid.bands[I].Free;
You then create the header bands
CreateBands('Prime key Header',YourGrid);
CreateBands('Main Title 1 Header',YourGrid);
CreateBands('Main Title 2 Header',YourGrid);
You then hook up your columns to the Bands 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;