2

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

Ravaut123
  • 2,764
  • 31
  • 46
Alain V
  • 311
  • 3
  • 17
  • 1
    Create a calculated field on FDMemTableClient ? – Jason Mar 10 '15 at 02:55
  • 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 Mar 10 '15 at 03:25
  • @jason: If my FDMemtable does not have Fields but only FiledsDef, how can we create a calculeted field ? – Alain V Mar 10 '15 at 03:33
  • 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 runtime – Jason Mar 10 '15 at 03:46

2 Answers2

2

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

Alain V
  • 311
  • 3
  • 17
1

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;
House of Dexter
  • 386
  • 1
  • 7