Jump to content

TUniDBLookupCombobox designtime vs runtime


Erik

Recommended Posts

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?

image.png.c86b39e521701a5141741d4becddc886.png

Link to comment
Share on other sites

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?

image.png.c86b39e521701a5141741d4becddc886.png

Do you have an active DataSource for lComboEdt?

Link to comment
Share on other sites

'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)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...