1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Panel1: TPanel;
Panel2: TPanel;
StringGrid1: TStringGrid;
Edit1: TEdit;
Edit2: TEdit;
procedure FormCreate(Sender: TObject);
procedure StringGrid1TopLeftChanged(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Panel : Tpanel;
MemoRow : Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
Var
i: Integer;
begin
StringGrid1.colCount := 63;
StringGrid1.RowCount := 63;
StringGrid1.DefaultColWidth := 20;
StringGrid1.DefaultRowHeight := 20;
For i:=1 to 62 do
Begin
StringGrid1.Cells[i,0] := IntToStr(i);
StringGrid1.Cells[0,i] := IntToStr(i);
end;
Panel := TPanel.Create(Self);
Panel.Parent := Self.StringGrid1;
Panel.Name := 'ici1';
Panel.Caption := 'ici1';
Panel.Height := 20;
Panel.Width := 30;
Panel.Left := StringGrid1.ColWidths[1]*2;
Panel.Top := StringGrid1.DefaultRowHeight;
Panel := TPanel.Create(Self);
Panel.Parent := Self.StringGrid1;
Panel.Name := 'ici2';
Panel.Caption := 'ici2';
Panel.Height := 20;
Panel.Width := 30;
Panel.Left := StringGrid1.ColWidths[1]*10;
Panel.Top := StringGrid1.DefaultRowHeight*2;
Panel := TPanel.Create(Self);
Panel.Parent := Self.StringGrid1;
Panel.Name := 'ici3';
Panel.Caption := 'ici3';
Panel.Height := 20;
Panel.Width := 30;
Panel.Left := StringGrid1.ColWidths[1]*5;
Panel.Top := StringGrid1.DefaultRowHeight*5;
MemoRow := StringGrid1.LeftCol;
end;
procedure TForm1.StringGrid1TopLeftChanged(Sender: TObject);
Var
OldRow : Integer;
begin
oldRow := StringGrid1.TopRow;
if oldRow > MemoRow then
Panel.Top := Panel.Top - StringGrid1.DefaultRowHeight
else
Panel.Top := Panel.Top + StringGrid1.DefaultRowHeight;
MemoRow := oldRow;
StringGrid1.Refresh;
end;
end. |
Partager