Erik Posted May 6, 2022 Share Posted May 6, 2022 Situation: 1 Form with 1 UniDBLookupCombobox and 1 button. When click on the button a second UniDBLookupCombobox is created and both lookupcomboboxs are initialized procedure TFrmTest.UniButton1Click(Sender: TObject); var lTblDs : TDataset; lTblLookupDs : TDataset; lDataSourceLookup : TDataSource; lComboEdt: TUniDBLookupComboBox; begin lTblDs := TDmMain.Instance.GetTabel(1); //DataSourceTbl is TDataSource designtime DataSourceTbl.DataSet := lTblDs; lTblLookupDs := TDmMain.Instance.GetLookupTabel(2); //Initialize lCombo Created at designtime lCombo.DataSource := DataSourceTbl; lCombo.KeyField := ucFLD_DOM_ID; lCombo.ListField := ucFLD_DOM_TEXT; lCombo.ListSource := lLstDs; lCombo.DataField := ucFLD_TBLDEF_TYPE_DM; lCombo.ForceSelection := True; lCombo.Update; //Initialize lComboEdt Created at runtime lDataSourceLookup := TDataSource.Create(self); lDataSourceLookup.DataSet := lTblLookupDs; lComboEdt:= TUniDBLookupComboBox.Create(Self); lComboEdt.Parent := Self; lComboEdt.Top := lCombo.Top+30; lComboEdt.Left := lCombo.Left; lComboEdt.DataSource := DataSourceTbl; lComboEdt.KeyField := 'ID'; lComboEdt.ListField := 'NAME'; lComboEdt.ListSource := lDataSourceLookup; lComboEdt.DataField := 'CLIENT_ID'; lComboEdt.ForceSelection := True; lComboEdt.Show; lComboEdt.Update; //Extra added because this is also in dfm at designtime lComboEdt.ListFieldIndex := 0; lComboEdt.TabOrder := 1; lComboEdt.Color := clWindow; lComboEdt.FieldLabelFont.Name := 'Segoe UI'; lComboEdt.Update; end; lCombo is shown correct. lComboEdt do not display the text. Why? Quote Link to comment Share on other sites More sharing options...
Eugeniusz Rink Posted May 6, 2022 Share Posted May 6, 2022 1 hour ago, Erik said: Situation: 1 Form with 1 UniDBLookupCombobox and 1 button. When click on the button a second UniDBLookupCombobox is created and both lookupcomboboxs are initialized procedure TFrmTest.UniButton1Click(Sender: TObject); var lTblDs : TDataset; lTblLookupDs : TDataset; lDataSourceLookup : TDataSource; lComboEdt: TUniDBLookupComboBox; begin lTblDs := TDmMain.Instance.GetTabel(1); //DataSourceTbl is TDataSource designtime DataSourceTbl.DataSet := lTblDs; lTblLookupDs := TDmMain.Instance.GetLookupTabel(2); //Initialize lCombo Created at designtime lCombo.DataSource := DataSourceTbl; lCombo.KeyField := ucFLD_DOM_ID; lCombo.ListField := ucFLD_DOM_TEXT; lCombo.ListSource := lLstDs; lCombo.DataField := ucFLD_TBLDEF_TYPE_DM; lCombo.ForceSelection := True; lCombo.Update; //Initialize lComboEdt Created at runtime lDataSourceLookup := TDataSource.Create(self); lDataSourceLookup.DataSet := lTblLookupDs; lComboEdt:= TUniDBLookupComboBox.Create(Self); lComboEdt.Parent := Self; lComboEdt.Top := lCombo.Top+30; lComboEdt.Left := lCombo.Left; lComboEdt.DataSource := DataSourceTbl; lComboEdt.KeyField := 'ID'; lComboEdt.ListField := 'NAME'; lComboEdt.ListSource := lDataSourceLookup; lComboEdt.DataField := 'CLIENT_ID'; lComboEdt.ForceSelection := True; lComboEdt.Show; lComboEdt.Update; //Extra added because this is also in dfm at designtime lComboEdt.ListFieldIndex := 0; lComboEdt.TabOrder := 1; lComboEdt.Color := clWindow; lComboEdt.FieldLabelFont.Name := 'Segoe UI'; lComboEdt.Update; end; lCombo is shown correct. lComboEdt do not display the text. Why? Do you have an active DataSource for lComboEdt? Quote Link to comment Share on other sites More sharing options...
Erik Posted May 13, 2022 Author Share Posted May 13, 2022 'Do you have an active DataSource for lComboEdt?' Anwser: Yes. The lComboEdt can be used is you dropdown the arrow. And also when I check the itemindex the value is >-1 (In my case 1) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 13, 2022 Share Posted May 13, 2022 1 minute ago, Erik said: 'Do you have an active DataSource for lComboEdt?' Anwser: Yes. The lComboEdt can be used is you dropdown the arrow. And also when I check the itemindex the value is >-1 (In my case 1) Hello, Can you please make a simple testcase to check? Quote Link to comment Share on other sites More sharing options...
Abanto Jose Posted January 21, 2023 Share Posted January 21, 2023 How did you solve this? Quote Link to comment Share on other sites More sharing options...
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.