Hello to everybody.
I need to add a button to each cell and use one click function.
Unfortunately I get an error Access violation at address ...
Thank you all.
Daniel
public
{ Public declarations }
procedure btnChangeSClick(Sender: TObject);
...
...
procedure TfrmMain.btnChangeSkupinaClick(Sender: TObject);
begin
frmSelectS.gridName := 'TEST';
frmSelectS.ShowModal;
end;
procedure TfrmMain.grid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
Field: TField;
fixRect : TRect;
btnChangeS: TButton;
begin
Field := Column.Field;
if (Column.Index = 0) then
begin
try
btnChangeS.Create(grid1);
btnChangeS.Parent := grid1;
btnChangeS.Visible := True;
btnChangeS.Caption := '...';
btnChangeS.Width := 25;
btnChangeS.Height := (Rect.Bottom - Rect.Top) - 2;
btnChangeS.Left := (Rect.Left + Rect.Width) - (btnChangeS.Width +1);
btnChangeS.Top := Rect.Top + 1;
btnChangeS.OnClick := btnChangeSClick;
grid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
except
On E: exception do
begin
ShowMessage(E.Message);
end;
end;
end;
end;