PRODUCTS » Quick Links

FEATURED PRODUCT

Create modern-looking & feature-rich applications with over 300 components including award-winning grids, scheduling components, Office 2010/2007/2003 ribbon & toolbars, calendars, application update and much more...

License only 195 EUR See More

LOGIN

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

SEARCH

STAY IN TOUCH

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

 

LINKS

PRODUCTS » VCL COMPONENTS » TADVSTRINGGRID » 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.

Copyright © 1995 - 2012 TMS Software v3.4