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
|
Const
WM_INSERTROW = WM_USER +1;
WM_DELETEROW = WM_USER +2;
TForm1 = Class(TForm)
...
Protected
procedure WMINSERTROW (var Message: TMessage); message WM_INSERTROW;
procedure WMDELETEROW (var Message: TMessage); message WM_DELETEROW;
...
end;
procedure TForm1.WMDELETEROW (var Message: TMessage);
var
a:integer;
begin
for a:= 0 to colonne do
ALTAGrid1.Columns.Items[a].Title := ALTAGrid1.Cells[a,0] ;
ALTAGrid1.DeleteRow(0);
end;
procedure TForm1.WMINSERTROW (var Message: TMessage);
var
a:integer;
begin
ALTAGrid1.InsertRow(0);
for a:= 0 to colonne do
begin
ALTAGrid1.Cells[a,0] := ALTAGrid1.Columns.Items[a].Title ;
ALTAGrid1.Columns.Items[a].Title := 'Champ ' + inttostr(a+1) ;
end;
end;
procedure TForm1.ALTACheckBox1Click(Sender: TObject);
begin
try
ALTACheckBox1.Enabled := FALSE;
if ALTACheckBox1.Checked = false then
PostMessage (handle,WM_INSERTROW,0,0)
else
PostMessage (handle,WM_DELETEROW,0,0);
finally
ALTACheckBox1.Enabled := TRUE;
application.ProcesssMessages;
end;
end; |
Partager