unit STest; interface uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons, ExtCtrls, Grids, Menus; type TSelfTest = class(TForm) OKBtn: TButton; SgST: TStringGrid; pmsys: TPopupMenu; btnCopyResult: TBitBtn; procedure btnCopyResultClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var SelfTest: TSelfTest; procedure AutoSizeGridColumn(Grid : TStringGrid; column : integer); implementation uses Unit1; {$R *.dfm} procedure AutoSizeGridColumn(Grid : TStringGrid; column : integer); var i : integer; temp : integer; max : integer; begin max := 0; for i := 0 to (Grid.RowCount - 1) do begin temp := Grid.Canvas.TextWidth(grid.cells[column, i]); if temp > max then max := temp; end; Grid.ColWidths[column] := Max + Grid.GridLineWidth + 10; end; procedure TSelfTest.btnCopyResultClick(Sender: TObject); begin form1.SltestToClipboard(1048000); end; end.