Ver Mensaje Individual
  #1  
Antiguo 05-05-2016
leg128 leg128 is offline
Registrado
NULL
 
Registrado: jun 2014
Posts: 5
Reputación: 0
leg128 Va por buen camino
Error "A control cannot have itself as its parent"

Buenos dias, les comento... estoy tratando de crear objetos(botones, edit y demas cosas que se me ocurran) en una grilla.. cuando ejecuto el programa recibo este error al hacer la llamada a mi procedimiento
"A control cannot have itself as its parent"

la llamada es
Código:
  stgboton(1, StringGrid1, 'hola', EventoClick, 5 );
el procedimiento es este
Código:
procedure stgboton(objeto:integer; Grid : TStringGrid; txtcaption:string; evento:TNotifyEvent; columna:integer);
var
 i: Integer;
  Btn: TObject;

begin
 for i := Grid.FixedRows to Grid.RowCount -2 do
  begin
    if objeto = 1 then
    begin
    with TButton (btn) do
    begin
       Create(nil);
       Caption   := txtboton;
       Width     := 87;
       Name      := 'Button' + IntToStr(i);
       BoundsRect:= Grid.CellRect(Columna, i);
       ControlStyle := [csClickEvents];
       onclick    := evento;
       Tag       :=  i;
       parent:= grid;
    end;
     Grid.Objects[Columna,i] := Btn;

    end;
  end;
end;
Alguna idea de como puedo solucionarlo? saludos.
Responder Con Cita