Fórum propriedade visible em grupo #299143
11/10/2005
0
Um exemplo:
Tenho 12 edits:
editA1 editB1 editC1 editA2 editB2 editC2 editA3 editB3 editC3 editA4 editB4 editC4 editA5 editB1 editC5 ...
Tenho uma variavel integer, ´param´.
De acordo com o valor dela eu gostaria de deixar os edits abaixo invisíveis.
No caso se param é 1, todos os edits a baixo do 1 ficam invisiveis, se é 2 todos os edits abaixo do 2 ficam invisíveis, e assim sucessivamente.
Mas no caso eu tenho 12 edits.
Eu poderia fazer um case na variavel, e ir fazendo na mão um por um, mas imaginem a quantidade de linhas que vai dar isso...
Será que tem alguma maneira diferente para essa situação ?
Obrigado.
Lynx
Curtir tópico
+ 0Posts
11/10/2005
Lynx
procedure linha1
nome dos edits1
.. ..2
.. ..2
isso já diminui bastante, mas mesmo assim da muita linha, será que tem algo diferente para essa situação.
Gostei + 0
11/10/2005
Imoreira
var
x,y,z,param:integer;
begin
param:=2;
for y:=0 to painel.controlcount-1 do begin
z:= strtoint(copy((painel.controls[y] as tedit).name,pos(´Edit´,(painel.controls[y] as tedit).name)+4,2));
for x:=param to painel.controlcount-1 do begin
if (z=x) then begin
(painel.controls[x] as tedit).visible:=false;
end;
end;
end;
end;
Gostei + 0
11/10/2005
Lynx
Acabei fazendo da maneira que postei acima...
Ficou bem menor.
Mas fiquem a vontade para postar outras maneiras.
valeu
Gostei + 0
11/10/2005
Marcio.theis
var x: integer; texto: String; begin for x:=0 to Self.ComponentCount - 1 do begin if Self.Components[x].ClassType = TEdit then begin texto:=(Self.Components[x] as TEdit).Name; texto:=Copy(texto,Length(texto),1); if StrToInt(texto) > param then (Self.Components[x] as TEdit).Visible:=False; end; end;
Gostei + 0
11/10/2005
Lynx
Certeza vai diminuir mais ainda.
valeu
Gostei + 0
11/10/2005
Marcio.theis
var x: integer; begin for x:=0 to Self.ComponentCount - 1 do begin if Self.Components[x].ClassType = TEdit then if (Self.Components[x] as TEdit).Tag > param then (Self.Components[x] as TEdit).Visible:=False; end;
Gostei + 0
11/10/2005
Lynx
valeu mesmo
Gostei + 0
11/10/2005
Lynx
Exemplo em TLabel, e TEDit ao mesmo tempo
Gostei + 0
11/10/2005
Marcio.theis
var x: integer; begin for x:=0 to Self.ComponentCount - 1 do begin if Self.Components[x].ClassType = TEdit then begin if (Self.Components[x] as TEdit).Tag > param then (Self.Components[x] as TEdit).Visible:=False; end else begin if Self.Components[x].ClassType = TLabel then if (Self.Components[x] as TLabel).Tag > param then (Self.Components[x] as TLabel).Visible:=False; end end; end;
Gostei + 0
11/10/2005
Lynx
Está voando agora
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)