Fórum Componente Dinâmico #331948
24/10/2006
0
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?
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
Curtir tópico
+ 0
Responder
Posts
26/10/2006
Micheus
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
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)