How to concatenate 2 fields from a dataset using LiveBindings?

不打扰是莪最后的温柔 提交于 2019-12-11 11:42:28

问题


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.

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


回答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;



回答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



来源:https://stackoverflow.com/questions/28955079/how-to-concatenate-2-fields-from-a-dataset-using-livebindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!