Fórum Duvida Cruel QRLabels #195591
18/11/2003
0
(´qrl´ + inttostr(Count)).caption := variavel;
Como eu poderia fazer isso ???
Neoramza
Curtir tópico
+ 0Posts
18/11/2003
Raserafim
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to 5 do
if Components[I] is TEdit then
TEdit(Components[I]).Text := ´Rodrigo´;
end;
Gostei + 0
18/11/2003
Neoramza
Gostei + 0
18/11/2003
Raserafim
TEdit(Components[I]).Text := variável;
já vai ficar como você havia perguntado. Não estou entendendo como você quer atribuir valores diferentes que código não funciona. Me dê mais detalhes que posso tentar ajudar.
Gostei + 0
18/11/2003
Neoramza
qrLabel1.caption := txtText1.caption;
qrLabel2.caption := txtText2.caption;
qrLabel3.caption := txtText3.caption;
....
qrLabel300.caption := txtText300.caption;
ao em vez de escrever tudo um por um eu queria usar um comando FOR para fazer isso.
Será que agora eu conseguir me expressar bem? :?
Gostei + 0
18/11/2003
Einstein
então, se vc usar o loop FOR basta passar a variavel contadora pra nome dos Componentes. Ex.: QRLabel+InttoStr(I).Caption:=Edit+StrToInt(I).Text;
Gostei + 0
18/11/2003
Beppe
Então você cria dois arrays, um para os labéis e outro para os edits.
type TForm1 = class(TForm) ... private QRLabels: array[1..300] of TQRLabel; Edits: array[1..300] of TEdit; procedure InitializeArrays; ... end; procedure TForm1.InitializeArrays; var I: Integer; Labs, Eds: Integer; begin Labs := 0; Eds := 0; for I := 0 to ComponentCount - 1 do begin if Components[I] is TQRLabel then begin Inc(Labs); QRLabels[Labs] := Components[I]; end else if Components[I] is TEdit then begin Inc(Eds); Edits[Eds] := Components[I]; end; end; end; ... for I := 1 to 300 do QRLabels[I].Caption := Edits[I].Text; ...
Gostei + 0
18/11/2003
Neoramza
Eu tentei fazer isso assimdentro do FOR:
QRLabel+InttoStr(I).Caption:=Edit+Inttostr(I).Text;
mas dava a seguinte mensagem de erro: ´Undeclared identifier: ´Edit´, ´QRLabel´
entao eu tentei fazer assim:
´QRLabel´+InttoStr(I).Caption:=´Edit´+Inttostr(I).Text;
agora o erro mudou para: Record, objct or data Type required
Não sei mais o que fazer. O q q deu errado ae?
Gostei + 0
18/11/2003
Neoramza
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)