PRODUCTS

FEATURED PRODUCT

The most powerful, fastest & flexible suite for native Excel file manipulation and Excel,PDF,HTML report generation for .NET

License only 125 EUR See More

SEARCH

LOGIN

Customer login to access products, support information & special benefits.

NEWS ALERTS

Add your e-mail address here to receive the monthly TMS Software alerts.

 

LINKS

EXAMPLE 39

TAdvStringGrid

example 39 : merged cell access and merged cell printing and HTML export

TAdvStringGrid

This demo app demonstrates the behaviour of merged cells. The access and settings that affect the merged cells are all done through the base cell, ie. the top left cell. This includes setting of cell content as well as performing cell settings through events. Cell merging is started with the call grid.MergeCells(ACol,ARow,SpanX,SpanY: Integer). ACol,ARow indicate the base cell, while SpanX, SpanY indicate the number of cells to merge horizontally and vertically. It is evident that the minimum values for SpanX, SpanY are 1 (that is no merging)

Example :

To set a long text in 10 horizontally merged cells you can:

AdvStringGrid1.MergeCells(1,6,10,1); AdvStringGrid1.Cells[1,6] := 'This another one that is long too';

The background color of this merged cell can be set by changing the background color of the base cell, ie :

AdvStringGrid.Colors[1,6] := clLime;

To reapply the default color, use :

AdvStringGrid.Colors[1,6] := clNone;

If you want to use the OnGetCellColor event to set colors, it is sufficient to handle the base cell color setting, for example in this way:

procedure AdvStringGrid1GetCellColor(Sender: TObject; ACol,ARow: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);

begin
  if ACol = 1 then 
  begin
    AFont.Color := clBlue
    AFont.Style := [fsBold];
  end;
end;


Delphi project & source files for downloading included in the main demos distribution for Delphi.

The project and source files have been written with Delphi 6,7. To use these files in other versions of Delphi, ignore any remarks when opening the form files and save the files. After this, compilation can be done. The error messages are due to properties included in the Delphi 6 form file, but not available in lower versions of Delphi.  

Copyright © 1995 - 2008 TMS Software