Tutorials to .com

Tutorials to .com » Software » Delphi » TStringGrid adaptive so that the width of

TStringGrid adaptive so that the width of

Print View , by: iSee ,Total views: 25 ,Word Count: 138 ,Date: Sat, 22 Aug 2009 Time: 4:07 AM

procedure AutoFitable (AGrids: TStringGrid);
/ / Incoming TStringGrid like you, 2004/10/28, CoolSlob
var
I, J: Integer;
MaxLenRow: Integer;
CurRowLen: Integer;
begin
inherited;
for J: = 0 to AGrids.ColCount - 1 do
begin
MaxLenRow: = 0;
for I: = 1 to AGrids.RowCount - 1 do
begin
CurRowLen: = AGrids.Canvas.TextWidth (Trim (AGrids.Cells [J, I]));
/ / Adaptive width, when the value is less than the maximum width W when the title to the title, whichever is wide.
if AGrids.Canvas.TextWidth (Trim (AGrids.Cells [J, 0]))> CurRowLen then
CurRowLen: = AGrids.Canvas.TextWidth (Trim (AGrids.Cells [J, 0]));
if CurRowLen> MaxLenRow then
begin
MaxLenRow: = CurRowLen + 5;
AGrids.ColWidths [J]: = MaxLenRow;
end;
end;
end;
end;


Delphi Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.