Venon Posted September 4, 2019 Posted September 4, 2019 I have a UniDBLookupComboBox on a form that has the listsource property bound to a datasource that is bound to a TFDQuery. In this form I have a button that opens another form where I insert into the database in the same table to which my UniDBLookupComboBox pulls the items. What happens is that right after I register a new record in the table, and trying to use KeyValue with the new item is not setting the value in UniDBLookupComboBox. Note: clicking on the combo already appears the new item in the list. Does anyone know the best way to do this? My code: procedure TFormOrdemServico.imgPesquisaCombustivelClick(Sender: TObject); var FormCadastroCombustivel : TFormCadastroCombustivel; begin if UniApplication.FindComponent('FormCadastroCombustivel') <> nil then Exit; ShowMask('Aguarde...'); UniSession.Synchronize(); FormCadastroCombustivel := TFormCadastroCombustivel.Create(UniApplication); HideMask; FormCadastroCombustivel.ShowModal(); cbCombustivel.ListSource.DataSet.Refresh; if FormCadastroCombustivel.ModalResult = mrOk then begin cbCombustivel.KeyValue := FormCadastroCombustivel.qryTemplateCOMBICOD.AsInteger; end; FreeAndNil(FormCadastroCombustivel); end; Quote
Sherzod Posted September 4, 2019 Posted September 4, 2019 5 hours ago, Multistore said: I have a UniDBLookupComboBox on a form that has the listsource property bound to a datasource that is bound to a TFDQuery. In this form I have a button that opens another form where I insert into the database in the same table to which my UniDBLookupComboBox pulls the items. What happens is that right after I register a new record in the table, and trying to use KeyValue with the new item is not setting the value in UniDBLookupComboBox. Note: clicking on the combo already appears the new item in the list. Does anyone know the best way to do this? Hello, Can you please specify, which edtion and build of UniGUI are you using? Quote
Venon Posted September 5, 2019 Author Posted September 5, 2019 22 hours ago, Sherzod said: Hello, Can you please specify, which edtion and build of UniGUI are you using? I am using version 1.0 Quote
Sherzod Posted September 5, 2019 Posted September 5, 2019 1 minute ago, Multistore said: I am using trial version version 1.0 First of all, if you are testing, then use the latest trial version! Quote
Venon Posted September 5, 2019 Author Posted September 5, 2019 ok, but to set the value of a TUniDBLookuptComboBox would not be: MyComboBox.KeyValue? Quote
Venon Posted September 5, 2019 Author Posted September 5, 2019 I noticed that this problem only occurs when saving a new database record, if KeyValue does not save it works normally. When I save a new item in the database it does not update UniDBLookupComboBox text when using KeyValue. I tried using the UpdateText method of UniDBLookupComboBox, when I did that the text updated with the description of the new record, but if I don't save any records and trying to use KeyValue doesn't update the combo text. Any idea? 1 Quote
cardoso Posted October 22, 2019 Posted October 22, 2019 Same problem here.. I'm using trial version 1.90 (latest disponible). UniDBLookupComboBoxBank.ListSource := FBankController.ReturnDataSource; // Other settings are on .dfm, and it show properly all itens from the database UniDBLookupComboBoxBank.KeyValue := FBankEntity.ID; // It makes no change at all. The KeyField on the component is correct, the record exists, the ID is correct... I need this to complete my tests on the framework to consider buying it. Quote
cardoso Posted October 22, 2019 Posted October 22, 2019 6 hours ago, cardoso said: Same problem here.. I'm using trial version 1.90 (latest disponible). UniDBLookupComboBoxBank.ListSource := FBankController.ReturnDataSource; // Other settings are on .dfm, and it show properly all itens from the database UniDBLookupComboBoxBank.KeyValue := FBankEntity.ID; // It makes no change at all. The KeyField on the component is correct, the record exists, the ID is correct... I need this to complete my tests on the framework to consider buying it. I found what i was doing wrong... The "KeyValue" field should be set when the "TUniDBLookupComboBox" is fully loaded. I changed the event "OnShow" for "OnReady" and it worked. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.