Вроде сделал компоненту Стринггрид с возможностью сортировки, но при использованию компоненты ничего не происходит тоисть текст в стринггриде не меняется - что я нетак делаю или компонента сделана не так? Подскажите пожалуйста, очень надо.
| Код | unit StringGrid1;
interface
uses SysUtils, Classes, Controls, Grids;
type TStringGrid1 = class(TStringGrid) private a,n:integer; s:string; { Private declarations } protected { Protected declarations } public procedure sort; { Public declarations } published property Fa:integer read a write a default 1; property Fn:integer read n write n default 1; property Fi:integer read i write i default 1; property Fs:string read s; { Published declarations } end;
procedure Register;
implementation
procedure Register; begin RegisterComponents('WR', [TStringGrid1]); end;
procedure TStringGrid1.sort; var i:integer; begin for i:=1 to n-1 do if (cells[0,i]='') and (cells[1,i]='') and(cells[2,i]='') and(cells[3,i]='') then begin s:=cells[0,i]; cells[0,i]:=cells[0,i+1]; cells[0,i+1]:=s;
s:=cells[1,i]; cells[1,i]:=cells[1,i+1]; cells[1,i+1]:=s;
s:=cells[2,i]; cells[2,i]:=cells[2,i+1]; cells[2,i+1]:=s;
s:=cells[3,i]; cells[3,i]:=cells[3,i+1]; cells[3,i+1]:=s; n:=N-1; end; a:=1; while a<>0 do begin a:=0; for i:=1 to n-1 do if cells[0,i]> cells[0,i+1] then begin s:=cells[0,i]; cells[0,i]:=cells[0,i+1]; cells[0,i+1]:=s;
s:=cells[1,i]; cells[1,i]:=cells[1,i+1]; cells[1,i+1]:=s;
s:=cells[2,i]; cells[2,i]:=cells[2,i+1]; cells[2,i+1]:=s;
s:=cells[3,i]; cells[3,i]:=cells[3,i+1]; cells[3,i+1]:=s; a:=a+1; end; end; end;
end.
|
|