Recent

Author Topic: Merge title in a DBGRID  (Read 3822 times)

alexs_marc

  • New member
  • *
  • Posts: 8
Merge title in a DBGRID
« on: July 21, 2020, 03:11:27 pm »
Hi folks!

I would like to know if there is a way to group columns from a DBGRID in the title (merge). In Delphi I use a component called TMDBGRID that has this feature. I would like to do this on Lazarus without installing third party components.

Has anyone ever needed this and got a native solution?

Thanks!
Alexssandro Marcelino

rvk

  • Hero Member
  • *****
  • Posts: 6171
Re: Merge title in a DBGRID
« Reply #1 on: July 21, 2020, 04:22:18 pm »
This is not possible with TDBGrid.

But maybe you can check if TRxDBGrid can do this.
(It's downloadable via Package > Online Package Manager)

(screenshot? http://freepascal.ru/forum/viewtopic.php?f=18&t=4743#p39711)

Renato Ricci

  • New Member
  • *
  • Posts: 16
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: Merge title in a DBGRID
« Reply #2 on: May 25, 2021, 10:51:53 pm »
Hi Alex .. Did you manage to merge in the title?

Thanks.

alexs_marc

  • New member
  • *
  • Posts: 8
Re: Merge title in a DBGRID
« Reply #3 on: May 26, 2021, 02:39:12 am »
No buddy... I couldn't do it natively, I tried THeader to no avail. And then I used canvas as an alternative resource.

Alexssandro Marcelino

bpranoto

  • Full Member
  • ***
  • Posts: 136
Re: Merge title in a DBGRID
« Reply #4 on: May 26, 2021, 05:16:48 am »
Use TRxDBGrid from Rx. You can install it from the Online Package Manage.

It supports Columns Bands, footer,etc. like the attached picture.

« Last Edit: May 26, 2021, 05:18:35 am by bpranoto »

Renato Ricci

  • New Member
  • *
  • Posts: 16
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: Merge title in a DBGRID
« Reply #5 on: May 26, 2021, 01:53:35 pm »
Thanks Alessandro.. Since I already use TRxDBGrid, I will try what @bpranoto suggested.

@bpranoto, Did you set the bands at the collumn level or at the grid level? Cause I did not find any component property to accomplish it.

Thanks.

bpranoto

  • Full Member
  • ***
  • Posts: 136
Re: Merge title in a DBGRID
« Reply #6 on: May 26, 2021, 02:03:35 pm »
Thanks Alessandro.. Since I already use TRxDBGrid, I will try what @bpranoto suggested.

@bpranoto, Did you set the bands at the collumn level or at the grid level? Cause I did not find any component property to accomplish it.

Thanks.

To set Band title to adjacent columns set the title Columns like this:

Code: Pascal  [Select][+][-]
  1. Band := 'ITEM|';
  2. Kol := Grid.Columns.Add;
  3. Kol.Title.Caption := Band + 'KODE';
  4. Kol.Title.Alignment := taCenter;
  5. Kol.FieldName := 'ITEMCODE';
  6. //
  7. Kol := Grid.Columns.Add;
  8. Kol.Title.Caption := Band + 'DESCRIPTION';
  9. Kol.Title.Alignment := taCenter;
  10. Kol.FieldName := 'ITEMNAME';
  11.  


Renato Ricci

  • New Member
  • *
  • Posts: 16
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: Merge title in a DBGRID
« Reply #7 on: May 26, 2021, 02:15:48 pm »
@bpranoto.. the PIPE |caractere did the trick! I did not know that!

Thank you very much!

bpranoto

  • Full Member
  • ***
  • Posts: 136
Re: Merge title in a DBGRID
« Reply #8 on: May 26, 2021, 04:51:57 pm »
You're welcome! Rx is great!

 

TinyPortal © 2005-2018