Using TDBComboBox component

0

I have the following problem, when I select an item in the TDBComboBox when exiting the component it automatically selects the last record.

DM_BancoInsumos.IBQCons_ForneInsumos.Close;
DM_BancoInsumos.IBQCons_ForneInsumos.Open;
DBComboFornecedor.Items.Clear;
DBComboFornecedor.Items.Add('Selecione');
while DM_BancoInsumos.IBQCons_ForneInsumos.Eof = False do
begin
  DBComboFornecedor.Items.Add(DM_BancoInsumos.IBQCons_ForneInsumosCodFornecedor.Text);
  DM_BancoInsumos.IBQCons_ForneInsumos.Next;
end;

In the TDBComboBox component:

Style -> csDropDownList
DataSource -> Ds_ConsForncedores
DataFiel -> CodFornecedor

No DataSource

DataSet -> DM_BancoInsumos.IBQCons_ForneInsumos
    
asked by anonymous 08.08.2017 / 00:31

1 answer

0

Good night James
By the code that you posted the problem of the combobox appearing the last record is because you did a while not eof. So when it gets to the end in the while is the last regret that stays in the combo. If you want the first ADD you made (SELECT) to appear, just put the end of the while DBComboFolder.itemindex: = 0;

while DM_BancoInsumos.IBQCons_ForneInsumos.Eof = False do
begin
  DBComboFornecedor.Items.Add(DM_BancoInsumos.IBQCons_ForneInsumosCodFornecedor.Text);
  DM_BancoInsumos.IBQCons_ForneInsumos.Next;
end;

DBComboFornecedor.itemindex:=0;

I hope to understand your problem:)

    
08.08.2017 / 01:21