FindComponent

Delphi

08/04/2008

Olá, gostaria de saber se tem uma forma mais simples de fazer o seguinte:

(form1.findComponent(´editTeste´) as TEdit).text := ´edit teste´;
(form1.findComponent(´editTeste´) as TEdit).color := clBlue;
(form1.findComponent(´editTeste´) as TEdit).Top := 10;
(form1.findComponent(´editTeste´) as TEdit).Left := 20;
etc...

ou seja, tenho que ficar procurando o componente toda vez que for setar alguma propriedade. Teria alguma forma de buscar uma única vez e setar este componente, ou criar uma variável onde eu alteraria suas propriedades e assim o componente que procurei passaria a ter esses valores?


Rodrigoxcruz

Rodrigoxcruz

Curtidas 0

Respostas

Rodc

Rodc

08/04/2008

Cria um ponteiro para o componente:
var Ponteiro: TButton;
begin
    Ponteiro := form1.findComponent(´editTeste´) as TEdit;
    Ponteiro.text := ´edit teste´; 
    Ponteiro.color := clBlue; 
    Ponteiro.Top := 10; 
    Ponteiro.Left := 20; 
end;



GOSTEI 0
Rodc

Rodc

08/04/2008

Opâ, corrigindo o código:
var Ponteiro: TEdit; 
begin 
    Ponteiro := form1.findComponent(´editTeste´) as TEdit; 
    Ponteiro.text := ´edit teste´; 
    Ponteiro.color := clBlue; 
    Ponteiro.Top := 10; 
    Ponteiro.Left := 20; 
end; 



GOSTEI 0
Fknyght

Fknyght

08/04/2008

Ve se ajuda

with (form1.findComponent(´editTeste´) as TEdit) Do
  Begin
    text := ´edit teste´;
    color := clBlue;
    Top := 10;
    Left := 20;
end;



GOSTEI 0
POSTAR