TvPrintGrid:
Enhanced
printable StringGrid component.
Version
1.01
Most features are designed for runtime usage therefore there is no proper property editor as yet
Added
Grid Features:
Method:
LoadFromDataSet(DataSet:TdataSet)
Fills grid with data from DataSet
If FixedRows>0 and The Cells are Blank then Inserts Field Names into Row 0
If FixedCols>0 Inserts Row No into Column 0
Properties:
RowFont[Index:Integer]
: Tfont
Allows the setting of fonts by Row (Excluding Fixed Rows)
Allows overriding back colours for Rows
Set to False to prevent editing of certain columns. (Options GoEditing MUST be set to True)
CoBoolean: Prints True or False for Non Zero or Zero
CoText : Default as standard;
CoInteger: Right aligned Integer. Existing Text is rounded.
CoCurrency: Right aligns Values and sets to 2 decimal places when entered. On existing data Shows Right aligned to 2 decimal places.
CoFloat: As above to ?? decimal places
CoCurrencyNonZero: As CoCurrency but only shows non zero figures. Zero figures are displayed as blank
CoUpper: Converts entered text to Upper Case and shows existing as upper case.
DecimalPlaces : Integer Precision for CoFloat type above Range 1 to 10 default 4
OldRow : Integer Last Row Index (After entering new cell)
OldCol : Integer Last Column Index (After entering new cell)
Not always
perfect properties: (IE: Don’t edit during use)
SelectedCellFontColor : Tcolor Font colour for the selected cell
(Not used in printing)
SelectedCellBackColor : Tcolor Background colour for selected cell
(Not used in printing)
Print
Features:
Methods:
Print Call to print the grid as it is drawn. Orientation etc is automatic at present.
Properties:
TitleFont : Tfont Font for report page heading
ReportHeader
: String Text for
Report Heading
PrintPageHeading
: Boolean Print a report
heading
Notes
on Printing:
Grid prints as drawn on screen but including non visible
portions.
It is automatically orientated.
Gridlines:
Printed or not according to the options goHorzGridlines
& GoVertGridlines
However they are always printed in Fixed rows or Columns.
If Fixed rows and columns exist But not GridLines then a
frame is also drawn.
RowHeights[Index:Integer]
And
ColWidths[Index:Integer] are respected during printing.
Set ColWidths to 1 to hide a column.
!! ColWidths And RowHeights can be used to format labels
Remove FixedRows and FixedColumns and the options
goHorzGridlines & GoVertGridlines before printing to print with no lines.
Use RowBackcolor Or Row font to highlight header rows.
Planned Features for next version include:
Page Break Rows
Scale Figure
Orientation
More Editable Headers
Editable Left Margins
Decent Property editor
RowEdited Markers
ReportHeaderFont becomes TitleFont
Weird font errors were fixed. (Fixed 10:30pm 22nd
March)
Moral of story: Test first!
Enabled LoadFromDataSet Method
Latest update: 22nd March 2001
Version 1.01
Download Package: http://www.vintner.co.uk/delphi/tvprintgrid.zip
Source Code Available From: Nick Gabb
Vintner
Computer Systems
16
Station Road
Chesham
Buckinghamshire
HP5
1DH
England
Price $20 Single User + $5 per user
SOURCE IS LICENSED & NOT FOR DISTRIBUTION
Source E-mailed on receipt
Support for 1 year on purchase of source code
(International Money Order only at present)
Email: nick@vintner.co.uk
Code Sample for testing a few features:
procedure TForm1.Button1Click(Sender: TObject);
Var
A,B:Integer;
Begin
With
vStringGrid1 do
Begin
FixedRows:=1;
FixedCols:=1;
//Set
Options in the Object inspector
//Eg
GoEditing & GoHorzLine & GoVertline
Rowcount:=7;
Colcount:=6;
ColOptions[2]:=coUpper;
ColOptions[4]:=coCurrency;
Colwidths[2]:=50;
Colwidths[3]:=80;
Colwidths[5]:=220;
RowHeights[5]:=Round(DefaultRowHeight*2);
RowBackColor[3]:=clAqua;
RowFont[4]:=Label1.Font;
RowFont[2]:=Label2.Font;
For A:=0
to Colcount-1 do
For
B:=0 to Rowcount-1 do
Begin
Cells[A,B]:='Cell '+IntToStr(A)+' '+IntToStr(B);
End;
For A:=0
to Rowcount-1 do
Cells[4,A]:=IntToStr(A)+'.'+IntToStr(B);
End;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//Ensure the
grid has something in it
Button1.Click;
//Print it
vStringGrid1.Print;
end;