Recent

Author Topic: [SOLVED] mcGrid: Cells don't merge  (Read 209 times)

Jvan

  • Full Member
  • ***
  • Posts: 108
[SOLVED] mcGrid: Cells don't merge
« on: August 03, 2020, 11:43:42 pm »
I'm trying to merge some cells by using mcGrid with this code:

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.FormCreate(Sender: TObject);
  2. begin
  3.  
  4.   //Creación del Grid
  5.   grdAstCont := TMCStringGrid.Create(Self);
  6.   grdAstCont.Parent := self;
  7.   grdAstCont.Align := alClient;
  8.   grdAstCont.RowCount := 2;
  9.   grdAstCont.ColCount := 6;
  10.   grdAstCont.ScrollBars := ssVertical;
  11.   grdAstCont.BorderSpacing.Left:=10;
  12.   grdAstCont.BorderSpacing.Right:=10;
  13.   grdAstCont.FixedRows:=2;
  14.   grdAstCont.Options := [goFixedHorzLine, goFixedVertLine, goHorzLine, goVertLine, goRowSelect];
  15.  
  16.   grdAstCont.OnMergeCells := @MergeCellsHandler;  
  17.   grdAstCont.OnPrepareCanvas := @grdAstContPrepareCanvas;
  18.   grdAstCont.OnResize := @grdAstContResize;
  19.  
  20. end;
  21.  

And this:

Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.MergeCellsHandler(Sender: TObject; ACol, ARow: Integer;
  2.   var ALeft, ATop, ARight, ABottom: Integer);
  3. begin
  4.   if (ACol in [1..2]) and (ARow = 0) then begin
  5.     ALeft := 1;
  6.     ARight := 2;
  7.   end;
  8. end;
  9.  

It runs, but cells don't merge.
« Last Edit: August 04, 2020, 12:47:10 am by Jvan »

jamie

  • Hero Member
  • *****
  • Posts: 3516
Re: mcGrid: Cells don't merge
« Reply #1 on: August 04, 2020, 12:26:14 am »
it appears to me you maybe attempting to write a spread sheet program ?

 if that being the case I do believe there is a  spreadsheet program already you can use.

https://wiki.lazarus.freepascal.org/FPSpreadsheet


Does that interest you ?
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 7521
Re: mcGrid: Cells don't merge
« Reply #2 on: August 04, 2020, 12:33:44 am »
You also must add goColSpanning to the Options of the grid.

Code: Pascal  [Select][+][-]
  1. grdAstCont.Options := [goColSpanning, goFixedHorzLine, goFixedVertLine, goHorzLine, goVertLine, goRowSelect];
« Last Edit: August 04, 2020, 12:36:27 am by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Jvan

  • Full Member
  • ***
  • Posts: 108
Re: mcGrid: Cells don't merge
« Reply #3 on: August 04, 2020, 12:34:19 am »
it appears to me you maybe attempting to write a spread sheet program ?

 if that being the case I do believe there is a  spreadsheet program already you can use.

https://wiki.lazarus.freepascal.org/FPSpreadsheet


Does that interest you ?

I just want to merge header cells.

Jvan

  • Full Member
  • ***
  • Posts: 108
Re: mcGrid: Cells don't merge
« Reply #4 on: August 04, 2020, 12:38:08 am »
You also must add goColSpanning to the Options of the grid.

Code: Pascal  [Select][+][-]
  1. grdAstCont.Options := [goColSpanning, goFixedHorzLine, goFixedVertLine, goHorzLine, goVertLine, goRowSelect];

It works, thanks!

 

TinyPortal © 2005-2018