Como se usa o ComboBox?

Delphi

10/04/2004

Oi,

Alguém aí sabe como usar um combobox?
Eu estou tentando o seguinte, mas o Delphi diz que está faltando parametros na quarta linha...

DadosSistema.IQryComboCli.Open;
while not DadosSistema.IQryComboCli.Eof do
begin
  cboClientes.AddItem(DadosSistema.IQryComboCliCLINOMERS.Value);
  DadosSistema.IQryComboCli.Next;
end;


Obrigado!


Yankleber

Yankleber

Curtidas 0

Respostas

Adilsond

Adilsond

10/04/2004

Voce deve utilizar a propriedade Items.

cboClientes.Clear;
DadosSistema.IQryComboCli.Open; 
while not DadosSistema.IQryComboCli.Eof do 
begin 
  cboClientes.Items.Add(DadosSistema.IQryComboCliCLINOMERS.Value); 
  DadosSistema.IQryComboCli.Next; 
end;


Agora se voce além de querer mostrar o nome do cliente, deseja qua ao selecionar o cliente possa recuperar o código do mesmo.

Para montar a combo utilize:

cboClientes.Clear;
DadosSistema.IQryComboCli.Open; 
while not DadosSistema.IQryComboCli.Eof do 
begin 
  cboClientes.Items.AddObject(DadosSistema.IQryComboCliCLINOMERS.Value,TObject(DadosSistema.IQryComboCliCLICODIGO.AsInteger)); 
  DadosSistema.IQryComboCli.Next; 
end;



e para recuperar:

Codigo := LongInt(cboClientes.Items.Objects[cboClientes.ItemIndex]);



GOSTEI 0
POSTAR