PRODUCTS

FEATURED PRODUCT

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

License only 175 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 57

TAdvStringGrid

example 57 : using cell controls to show a grid inside a grid

TAdvStringGrid

With improved cell controls support, it is now possible to do something like using a grid inside a grid.

To start with, using cell controls is simple. Any TWinControl descendent can be hosted inside TAdvStringGrid. This is done by assigning the control to the grid.CellControls[col,row]: TWinControl property.

Example:

To have a button displayed in cell 2,5 you can use:

grid.CellsControls[2,5] := button1;

The same technique can be applied to put a grid inside a grid. Here some additional features will be used. First of all, the grid will be placed in a merged cell. Secondly, the merged cell will be put in a node span to allow collapsing and expanding the row with the secondary grid.

The setup is done by putting the main grids and two secondary grids on a form. With the following code, the secondary grids are bound in the merged  expandable rows of the main grid:

procedure TForm1.FormCreate(Sender: TObject);
begin
  advstringgrid1.LinearFill(false);
  advstringgrid1.AddNode(1,2);
  advstringgrid1.RowHeights[2] := 128;
  advstringgrid1.MergeCells(1,2,4,1);
  advstringgrid1.CellControls[1,2] := advstringgrid2;
  advstringgrid1.AddNode(3,2);
  advstringgrid1.RowHeights[4] := 128;
  advstringgrid1.MergeCells(1,4,4,1);
  advstringgrid1.CellControls[1,4] := advstringgrid3;
  advstringgrid1.ContractNode(1);
  advstringgrid1.ContractNode(3);
end;

As the secondary grids are placed on the form, all features and capabilities of TAdvStringGrid can be used on the main grid as well as on the secondary grids.

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