Merge cells in Band

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
Koot33
Newbie
Newbie
Posts: 2
Joined: Tue Mar 13, 2018 12:00 am

Merge cells in Band

Post by Koot33 » Tue Apr 03, 2018 5:45 pm

I want to group columns and have a heading for each group. I thought I would be able to do this with band headers but I can't see any way to do it. Any ideas?

Group 1 | Group 2
-------------------------------------------------------
G1C1 | G1C2 | G1C3 | G2C1 | G2C2 | G2C3
-------------------------------------------------------

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Merge cells in Band

Post by Yeray » Wed Apr 04, 2018 2:21 pm

Hello,

Taking the Header_Footer example, this seems to work fine for me here:

Code: Select all

type
  THouse=record
  public
    Address : String;
    Floors  : Integer;
  end;

  TPerson=record
  public
    Name   : String;
    Phone   : Integer;
  end;

  TPropriety=record
  public
    House: THouse;
    Owner: TPerson;
  end;

var
  Proprieties : TArray<TPropriety>;

procedure TFormHeaderFooter.FormCreate(Sender: TObject);
begin
  SetLength(Proprieties,2);
  Proprieties[0].House.Address:='123 St';
  Proprieties[0].House.Floors:=5;
  Proprieties[0].Owner.Name:='John';
  Proprieties[0].Owner.Phone:=666777888;

  Proprieties[1].House.Address:='456 St';
  Proprieties[1].House.Floors:=2;
  Proprieties[1].Owner.Name:='Marc';
  Proprieties[1].Owner.Phone:=666777666;

  TeeGrid1.Data:=TVirtualData<TArray<TPropriety>>.Create(Proprieties);
end;
TeeGrid_Header_Footer_2018-04-04_16-19-12.png
TeeGrid_Header_Footer_2018-04-04_16-19-12.png (4.3 KiB) Viewed 19738 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Koot33
Newbie
Newbie
Posts: 2
Joined: Tue Mar 13, 2018 12:00 am

Re: Merge cells in Band

Post by Koot33 » Wed Apr 04, 2018 3:16 pm

That does work (except for the column lines in the header). But, it is done completely automatically. My data does not fit that model so I want to know how to do that using code?

In the process of trying to figure out how to change the header text, I deleted the only entry in the "Headers" collection of the TeeGrid component. This caused unrecoverable errors in the IDE. Should I file a bug report?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Merge cells in Band

Post by Yeray » Tue Apr 10, 2018 7:05 am

Hello,
Koot33 wrote:That does work (except for the column lines in the header). But, it is done completely automatically. My data does not fit that model so I want to know how to do that using code?
We are investigating the options available to do this. We'll be back to you asap here.
Koot33 wrote:In the process of trying to figure out how to change the header text, I deleted the only entry in the "Headers" collection of the TeeGrid component. This caused unrecoverable errors in the IDE. Should I file a bug report?
I've just added it to the public tracker. Thanks for reporting it.
http://bugs.teechart.net/show_bug.cgi?id=2026
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Merge cells in Band

Post by Yeray » Wed Apr 18, 2018 1:43 pm

Hello,
Koot33 wrote:except for the column lines in the header
You could set the format brush to paint above that line. In the same example:

Code: Select all

  TeeGrid1.Columns[0].Header.ParentFormat:=False;
  TeeGrid1.Columns[0].Header.Format.Brush.Visible:=True;
  TeeGrid1.Columns[0].Header.Format.Brush.Color:=clGray;
  TeeGrid1.Columns[1].Header.ParentFormat:=False;
  TeeGrid1.Columns[1].Header.Format.Brush.Visible:=True;
  TeeGrid1.Columns[1].Header.Format.Brush.Color:=clGray;
TeeGrid_Header_Footer_2018-04-18_14-56-13.png
TeeGrid_Header_Footer_2018-04-18_14-56-13.png (3.99 KiB) Viewed 19583 times
Koot33 wrote:But, it is done completely automatically. My data does not fit that model so I want to know how to do that using code?
Still investigating the options we have for doing this manually.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Merge cells in Band

Post by Yeray » Tue Apr 24, 2018 1:40 pm

Hello,
Yeray wrote:
Koot33 wrote:But, it is done completely automatically. My data does not fit that model so I want to know how to do that using code?
Still investigating the options we have for doing this manually.
As TeeGrid is designed, you only can have subcolumns using a TVirtualData array with an structure of records and subrecords as in the Header_Footer example I mentioned in my first reply in this thread.
I've made an example of doing the same with a database here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply