combobox do delphi7 galera preciso de ajuda
GALERA É O SEGUINTE, REFERENTE AO COMBOBOX, EU ESTOU ESCREVENDO UM CADASTRO DE CLIENTE ONDE A PESSOA FISICA E JURIDICA, NO COMBOBOX EU DETERMINEI EM ITENS A LETRA (F) PARA PESSOA FISICA E (J) PARA PESSOA JURIDICA ATÉ AI TUDO BEM, MAIS QUERIA QUE AO SELECIONAR A OPÇÃO PESSOA FISICA (F) OS CAMPOS QUE SÃO DBEDIT DO CNPJ E IE FICA-SE DESABILITADOS ONDE NAO POSSIBILITASSE A INSERÇÃO DE NENHUM DADOS E ASSIM COM A OPÇÃO INVERSA ALGUEM PODE ME AUXILIAR NESTE CODIGO.???
EMAIL JOAOCARLOSVIEIRADOSSANTOS@HOTMAIL.COM DESDE JA AGRADEÇO A ATENÇÃO...
EMAIL JOAOCARLOSVIEIRADOSSANTOS@HOTMAIL.COM DESDE JA AGRADEÇO A ATENÇÃO...
Joao Vieiradossantos
Curtidas 0
Respostas
Rafael Cunha
17/12/2012
Implemento o Evento OnChange do ComboBox e faça algo parecido com o código abaixo:
if ComboBox1.Items[ComboBox1.ItemIndex] = 'F' then EdtCNPJ.Enabled := false; else EdtCNPJ.Enabled := true;
GOSTEI 0
Joao Vieiradossantos
17/12/2012
USANDO O CODIGO QUE VC ME DEU QUASE FUNCIONA
procedure TFrm_clientes.DBComboBox2Change(Sender: TObject);
begin
if DBComboBox2.Items[DBComboBox2.ItemIndex]='F'then
DBeditCNPJ.Enabled:=False;
DBeditIE.Enabled:=False;
ELSE
DBeditCNPJ.Enabled:=True;
DBeditIE.Enabled:=TRUE;
END;
end.
Build
[Error] U_CLIENTES.pas(240): ';' not allowed before 'ELSE'
[Fatal Error] COMMERCE.dpr(16): Could not compile used unit 'U_CLIENTES.pas'
procedure TFrm_clientes.DBComboBox2Change(Sender: TObject);
begin
if DBComboBox2.Items[DBComboBox2.ItemIndex]='F'then
DBeditCNPJ.Enabled:=False;
DBeditIE.Enabled:=False;
ELSE
DBeditCNPJ.Enabled:=True;
DBeditIE.Enabled:=TRUE;
END;
end.
Build
[Error] U_CLIENTES.pas(240): ';' not allowed before 'ELSE'
[Fatal Error] COMMERCE.dpr(16): Could not compile used unit 'U_CLIENTES.pas'
GOSTEI 0
Rafael Cunha
17/12/2012
Não se utiliza ";" antes de else em Delphi. Realizei as correções do seu código abaixo:
procedure TFrm_clientes.DBComboBox2Change(Sender: TObject);
begin
if DBComboBox2.Items[DBComboBox2.ItemIndex]='F'then
begin
DBeditCNPJ.Enabled:=False;
DBeditIE.Enabled:=False;
end
else
begin
DBeditCNPJ.Enabled:=True;
DBeditIE.Enabled:=TRUE;
end;
end;
end.
GOSTEI 0
Alan Souza
17/12/2012
tenta assim:
procedure TFrm_clientes.DBComboBox2Change(Sender: TObject); begin DBeditCNPJ.Enabled := DBComboBox2.Items[DBComboBox2.ItemIndex]='J'; DBeditIE.Enabled := DBeditCNPJ.Enabled; END;
GOSTEI 0
Joao Vieiradossantos
17/12/2012
procedure TFrm_clientes.DBComboBox2Change(Sender: TObject);
begin
if DBComboBox2.Items[DBComboBox2.ItemIndex]='F'then
begin
DBeditCNPJ.Enabled:=False;
DBeditIE.Enabled:=False;
end
else
begin
DBeditCNPJ.Enabled:=True;
DBeditIE.Enabled:=TRUE;
end;
begin
if DBComboBox2.items[DBComboBox2.ItemIndex]='J' then
begin
DBeditCPF.Enabled:=false;
DBeditRG.Enabled:=false;
DBeditTITULO.Enabled:=false;
DBeditZONA.Enabled:=false;
DBeditSECAO.Enabled:=false;
DBeditNASC.Enabled:=false;
end
else
begin
DBeditCPF.Enabled:=true;
DBeditRG.Enabled:=true;
DBeditTITULO.Enabled:=true;
DBeditZONA.Enabled:=true;
DBeditSECAO.Enabled:=true;
DBeditNASC.Enabled:=true;
end;
end;
end;
end.
amigo quero agradece-lo pela dica foi fundamental para a execução do me projeto desde ja agradeço sua atenção
muito obrigado
begin
if DBComboBox2.Items[DBComboBox2.ItemIndex]='F'then
begin
DBeditCNPJ.Enabled:=False;
DBeditIE.Enabled:=False;
end
else
begin
DBeditCNPJ.Enabled:=True;
DBeditIE.Enabled:=TRUE;
end;
begin
if DBComboBox2.items[DBComboBox2.ItemIndex]='J' then
begin
DBeditCPF.Enabled:=false;
DBeditRG.Enabled:=false;
DBeditTITULO.Enabled:=false;
DBeditZONA.Enabled:=false;
DBeditSECAO.Enabled:=false;
DBeditNASC.Enabled:=false;
end
else
begin
DBeditCPF.Enabled:=true;
DBeditRG.Enabled:=true;
DBeditTITULO.Enabled:=true;
DBeditZONA.Enabled:=true;
DBeditSECAO.Enabled:=true;
DBeditNASC.Enabled:=true;
end;
end;
end;
end.
amigo quero agradece-lo pela dica foi fundamental para a execução do me projeto desde ja agradeço sua atenção
muito obrigado
GOSTEI 0