<< Click to Display Table of Contents >> Navigation: Programming > Property Grids > AppendPropertyRow |
A simple, one dimensional grids can be dynamically created with the TParagraph function AppendPropertyRow.
function AppendPropertyRow(
aCaption: string = '';
aName : String = '';
Options : TAppendPropertyGridOptions = [wpapLine];
InplaceClass : String = ''; // the id name of the inplace editor, i.e. 'wpcubed.check'
FieldCommand : string = ''; // the command string is stored in WPAT_PAR_COMMAND.
FirstColumnWidth : Integer = 2000;
ModifyCellCallback : TWPAppendGridCallback = nil; // Modify the data cells
PropertyColCount : Integer = 1 // How many data columns should be created
) : TParagraph;
It must be called for a paragraph which is a table cell because they are created as nested tables.
Example:
var par : TParagraph;
i : Integer;
begin
par := WPRichText1.AddTable(1,1,true);
for I := 1 to 5 do
par.AppendPropertyRow('Row ' + IntToStr(i), 'NAME'+ IntToStr(i),
[wpapCreateInplaceEditor, wpapAppendInThisCell],
inplfrmID_check,'', 2000, AppendRowCallback, 2);
par.ParentTable.AppendNewPar();
WPRichText1.ReformatAll();
end;
The code above uses a call-back which is used to modify each individual checkbox:
procedure TForm1.AppendRowCallback( Parent, Cell : TParagraph; Row, Col : Integer; Data : TObject );
begin
if Col>0 then
begin
Cell.ASet(WPAT_COLWIDTH, 500);
with Cell.InplaceEditor do
begin
SetGUIProp(WPINPL_CHECK_PRP_ALIGNMENT, 1);
SetGUIProp(WPINPL_PRP_ID_V_PADDING, 1);
SetGUIProp(WPINPL_PRP_ID_H_PADDING, 0);
if Col=1 then
begin
group := 3;
SetGUIProp(WPINPL_CHECK_RADIO_GROUPLEVEL, CHK_RADIO_COL); // parent column
SetGUIProp(WPINPL_PRP_ID_COLOR, $FFFFA0);
end
else
begin
group := 4;
SetGUIProp(WPINPL_PRP_ID_COLOR, clWhite );
//SetGUIProp(WPINPL_CHECK_RADIO_GROUPLEVEL, CHK_RADIO_ROW); // parent row
end;
end;
end;
end;