1
I’d like to make one LookUpCombobox
in Delphi who behaved as follows:
- When the user clicked choosing Brazilian or Brazilian, Born Abroad or Naturalized, other
LookUpCombobox
was automatically selected as the country Brazil and was unavailable for change. - When the user selected Foreigner, the other
LookUpCombobox
would be blank and the user would have the option to choose the country, but could not choose Brazil.
When I click on Post to save the values, the Parents field is blank and not saved when it is Brazil. I made a showmessage()
in the variable and it returns the correct country code which is 76.
Follows the code:
procedure TformCadastroEstudantes.DBLookupComboBoxNacionalidadeCloseUp(
Sender: TObject);
var nacionalidade : Integer;
var pais : Integer;
var enabled : Boolean;
begin
nacionalidade := DBLookupComboBoxNacionalidade.KeyValue;
pais := DBLookupComboBoxPais.KeyValue;
enabled := True;
AtualizaPaises(nacionalidade, pais, enabled);
DBLookupComboBoxPais.KeyValue := pais;
DBLookupComboBoxPais.Enabled := enabled;
end;
Follow the code of procedure:
procedure AtualizaPaises(var nacionalidade : Integer; var pais: Integer; var enabled : Boolean);
begin
if ((nacionalidade = 1) OR (nacionalidade = 2)) then
begin
pais := 76;
enabled := False;
with dm.sqlPaises do
begin
Close;
SQL.Clear;
SQL.Add('select * from PAISES');
SQL.Add('where CODIGO_PAIS like ''76''');
SQL.Add('order by NOME_PAIS');
Open;
end;
end
else
begin
pais := 0;
enabled := True;
with dm.sqlPaises do
begin
Close;
SQL.Clear;
SQL.Add('select * from PAISES');
SQL.Add('where CODIGO_PAIS not like ''76''');
SQL.Add('order by NOME_PAIS');
Open;
end;
end;
end;
I don’t understand your question: you cite "naturalness: city and state of birth", but want to have two Lookupcombobox to select the country? Or you wrote by mistake "naturalness"?
– prmas
@Diego Felipe - Actually is nationality
– Luis Souza
@prmas - In fact it is nationality - First I have to know if it is Brazilian or Naturalized, if positive only Brazil as parents should be allowed, not being able to change. If foreign, all but Brazil may be allowed.
– Luis Souza
I don’t think I understand, try setting the Keyvalue property of the other Lookupcombobox to the desired value
– Passella