REVELAR

Fórum Maskedit recebe somente valores selecionados pelo checkbox? #336662

23/01/2007

0

Pessoal, tenho doze checkbox, e gostaria de quando mostrar este codigo
 if (FindComponent(´checkbox´+inttostr((Components[I] as TEdit).Tag and (components[i] as TMaskedit).Tag)) As tCheckBox).Checked then
        (Components[I] as TEdit).Text := edtValorPadrao.Text;

      Case (Components[I] as TMaskEdit).Tag of
          1: ijan.text     :=string( ´01/01/´+edtAno.Text );
          2: ifev.text     :=string( ´01/02/´+edtAno.Text );
          3: imar.text     :=string( ´01/03/´+edtAno.Text );
          4: iabr.text     :=string( ´01/04/´+edtAno.Text );
          5: imai.text     :=string( ´01/05/´+edtAno.Text );
          6: ijun.text     :=string( ´01/06/´+edtAno.Text );
          7: ijul.text     :=string( ´01/07/´+edtAno.Text );
          8: iago.text     :=string( ´01/08/´+edtAno.Text );
          9: iset.text     :=string( ´01/09/´+edtAno.Text );
         10: iout.text     :=string( ´01/10/´+edtAno.Text );
         11: inov.text     :=string( ´01/11/´+edtAno.Text );
         12: idez.text     :=string( ´01/12/´+edtAno.Text );
      end;

[b:4071fde998]Somente os que eu marcar no checkbox, tambem sao doze MaskEdits[/b:4071fde998]


Adriano_servitec

Adriano_servitec

Responder

Posts

24/01/2007

Adriano_servitec

Sobe...

Aqui esta o codigo completo

procedure TForm3.btnCarregarClick(Sender: TObject);
var
  i, n: SmallInt;
begin
  N := ComponentCount;
  for I := 0 to N-1 do
  begin

    if (Components[I] is TEdit) then
      if ((Components[I] as TEdit).Tag > 0) and ((Components[I] as TEdit).Tag < 37) then
      begin
        if (FindComponent(´checkbox´+inttostr((Components[I] as TEdit).Tag and (components[i] as TMaskedit).Tag)) As tCheckBox).Checked then
        (Components[I] as TEdit).Text := edtValorPadrao.Text;

      Case (Components[I] as TMaskEdit).Tag of
          13: ijan.text     :=string( ´01/01/´+edtAno.Text );
          14: ifev.text     :=string( ´01/02/´+edtAno.Text );
          15: imar.text     :=string( ´01/03/´+edtAno.Text );
          16: iabr.text     :=string( ´01/04/´+edtAno.Text );
          17: imai.text     :=string( ´01/05/´+edtAno.Text );
          18: ijun.text     :=string( ´01/06/´+edtAno.Text );
          19: ijul.text     :=string( ´01/07/´+edtAno.Text );
          20: iago.text     :=string( ´01/08/´+edtAno.Text );
          21: iset.text     :=string( ´01/09/´+edtAno.Text );
          22: iout.text     :=string( ´01/10/´+edtAno.Text );
          23: inov.text     :=string( ´01/11/´+edtAno.Text );
          24: idez.text     :=string( ´01/12/´+edtAno.Text );
      end;
      
     Case (Components[I] as TEdit).Tag of
          25: fjan.text     :=string( ´31/01/´+edtAno.Text );
          26: ffev.text     :=string( ´28/02/´+edtAno.Text );
          27: fmar.text     :=string( ´31/03/´+edtAno.Text );
          28: fabr.text     :=string( ´30/04/´+edtAno.Text );
          29: fmai.text     :=string( ´31/05/´+edtAno.Text );
          30: fjun.text     :=string( ´30/06/´+edtAno.Text );
          31: fjul.text     :=string( ´31/07/´+edtAno.Text );
          32: fago.text     :=string( ´31/08/´+edtAno.Text );
          33: fset.text     :=string( ´30/09/´+edtAno.Text );
          34: fout.text     :=string( ´31/10/´+edtAno.Text );
          35: fnov.text     :=string( ´30/11/´+edtAno.Text );
          36: fdez.text     :=string( ´31/12/´+edtAno.Text );
      end;
    end;  
  end;
end;


E, apareçe o seguinte erro:
[b:3a10ed8319]Invalid class typecast[/b:3a10ed8319] Acho que pode estar mandando os dados antes por isso o erro, pode ser nos IFs, nao sei ao certo.

Adriano.


Responder

Gostei + 0

24/01/2007

Adriano_servitec

Pessoal resolvi, nao sai aonde estava com a cabeça em usar este case

fiz da maneira que precisa escrever mais soh que funcionou como eu preciso

if checkbox1.checked = true then
begin
    ijan.text     :=string( ´01/01/´+edtAno.Text ); 
    fjan.text     :=string( ´31/01/´+edtAno.Text ); 
end;
if checkbox2.checked = true then
begin
    ifev.text     :=string( ´01/01/´+edtAno.Text ); 
    ffev.text     :=string( ´28/02/´+edtAno.Text ); 
end;

...
...

Acho que com um ARRAY facaria melhor. Mais nao seu como montar um :oops:


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar