2
votes

Is there a way to use the Live Binding Designer to concatenate 2 database fields to a component?

For example I have a MemTable for client, I want to concatenate the FirstName and LastName (fullname) to a label.

Live Binding Designer

If there is a way to do that, I understand that the binding will be in one direction only (Database fields --> ComponentProperty).

2
Create a calculated field on FDMemTableClient ?Jason
Thanks, this work. I think live binding can save time, but it s also a loosing time for simple task we do in anoher way !Alain V
@jason: If my FDMemtable does not have Fields but only FiledsDef, how can we create a calculeted field ?Alain V
TFDMemTable has a property FieldOptions. Set AutoCreateMode to acCombineComputed then just create your calculated field at design time. Otherwise search on how to create a Calculated Field at runtimeJason

2 Answers

2
votes

The easyest way to do with LiveBinding, is to use the CustomFormat property of the LinkFillControlToField :

Just use this format text as the example is the question: Self.Owner.FirstName.text + " " + Self.Owner.LastName.text

1
votes

For something simple like this...you can use the AfterScroll Event of your Dataset

  if Dataset.Active and (Dataset.RecordCount > 0) then  
    label1.Caption :=Dataset.FieldByName('FirstName').AsString + ' ' + Dataset.FieldByName('LastName').AsString;