.....
private
procedure
TForm
.
GridsDrawCell(Sender: TObject; ACol,
ARow:
Integer
; Rect: TRect; State: TGridDrawState);
......
procedure
TForm
.
GridsDrawCell(Sender: TObject; ACol,
ARow:
Integer
; Rect: TRect; State: TGridDrawState);
var
Format:
Word
;
C :
array
[
0..255
]
of
Char
;
temp, max, i, j :
integer
;
begin
Format := DT_Center
OR
DT_WORDBREAK;
(Sender
as
TStringGrid).Canvas
.
FillRect(Rect);
StrPCopy(C, (Sender
as
TStringGrid).Cells[ACol, ARow]);
WinProcs
.
DrawText((Sender
as
TStringGrid).Canvas
.
Handle, C, StrLen(C), Rect, Format);
with
Sender
as
TStringGrid
do
for
I :=
0
to
StringGrid
.
ColCount -
1
do
begin
max:=
0
;
for
J :=
0
to
StringGrid
.
RowCount -
1
do
begin
temp := StringGrid
.
Canvas
.
TextWidth(StringGrid
.
Cells[i, j]);
if
temp > max
then
max:=temp;
end
;
StringGrid
.
ColWidths[i] := max + StringGrid
.
GridLineWidth +
10
;
end
;
end
;