Componente Dinâmico

Delphi

24/10/2006

Criei um Edit dinamicamente:
EIrPara := TEdit.Create(TSQuestoes);
With EIrPara do
begin
Parent := TSQuestoes;
Name := ´EIrPara´ + IntToStr(I);
OnExit := IrParaSaida;
Text := ´´;
Left := 165;
Font.Size := 10;
Width := 30;
end;

Só que no evento que criei não consigo pegar o valor dentro do Edit:
procedure TFormAluno.IrParaSaida(sender: TObject);
begin
Try
StrToInt(EIrPara.Text);
If not ((StrToInt(EIrPara.Text) > 0) and
(StrToInt(EIrPara.Text) <= DMAluno.ADOQTesteQuestoes_Teste.AsInteger)) then
begin
Application.Messagebox(PChar(´A questão ´ + EIrPara.Text + ´ não existe !´),
´Aviso´, Mb_Ok + MB_ICONEXCLAMATION);
end;
Except
Application.Messagebox(´Valor Inválido !´, ´Aviso´,
Mb_Ok + MB_ICONEXCLAMATION);
end;
end;

Sempre esta vazio. Por exemplo, se digito 25 no campo o comando EIrPara.Text deveria me retornar 25.

O que deve ser?


Leufmt

Leufmt

Curtidas 0

Respostas

Micheus

Micheus

24/10/2006

O que deve ser?
[b:dd46551318]leufmt[/b:dd46551318], parece estranho mesmo. Já tentou fazer diferente?
Esperimente utilizar o Sender. Ele, normalmente, aponta para o componente chamador, neste caso o componente que vc criou dinamicamente:
procedure TFormAluno.IrParaSaida(sender: TObject);
begin
  with Sender as TEdit do
  Try
    StrToInt(Text);
    If not ((StrToInt(Text) > 0) and (StrToInt(Text) <= DMAluno.ADOQTesteQuestoes_Teste.AsInteger)) then
    begin
      Application.Messagebox(PChar(´A questão ´ + Text + ´ não existe !´),
´Aviso´, Mb_Ok + MB_ICONEXCLAMATION);
    end;
  Except
    Application.Messagebox(´Valor Inválido !´, ´Aviso´,
Mb_Ok + MB_ICONEXCLAMATION);
  end;
end;


[]s


GOSTEI 0
POSTAR