Introduction to Delphi xe2 firemonkey (30)-Data Binding: tbindingslist: onassigningvalue event of tbindexpression

Source: Internet
Author: User
The function in the expression is limited. For example, if I want to bind the length of the output text (for example, the length of the output edit1.text in label1), there is no corresponding function;

This can be handled in the onassigningvalue event of tbindexpression.

Tbindexpression and its brothers (tbindexpritems, tbindlink, tbindlistlink, marker, tbindposition, tbindlist, marker, tbinddbeditlink, marker, Token, tbinddbchecklink, and timeout) have the same events.

Add label1, edit1, and bindingslist1 to the form, and then activate the onkeyup event of edit1 and the default event of the form;

Code You have manually completed the onassingningvalue event. It is more convenient to add the event during design.
Unit unit1; interfaceuses system. sysutils, system. types, system. uitypes, system. classes, system. variants, FMX. types, FMX. controls, FMX. forms, FMX. dialogs, Data. BIND. engext, FMX. BIND. dbengext, system. rtti, system. bindings. outputs, FMX. layouts, Data. BIND. components, FMX. edit; Type tform1 = Class (tform) label1: tlabel; edit1: tedit; bindingslist1: dependencies; Procedure formcreate (Sender: tobject); Procedure edit1keyup (Sender: tobject; var key: word; var keychar: Char; shift: tshiftstate); Procedure myonassigningvalue (Sender: tobject; assignvaluerec: handle; VaR value: tvalue; var handled: Boolean); end; var form1: tform1; implementation {$ R *. FMX} procedure tform1.formcreate (Sender: tobject); begin with tbindexpression. create (bindingslist1) Do begin controlcomponent: = label1; controlexpression: = 'text'; sourcecomponent: = edit1; sourceexpression: = 'text'; onassigningvalue: = myonassigningvalue; // active: = true; end; Procedure tform1.edit1keyup (Sender: tobject; var key: word; var keychar: Char; shift: tshiftstate); begin bindingslist1.notify (sender, ''); end; procedure tform1.myonassigningvalue (Sender: tobject; assignvaluerec: tbindingassignvaluerec; VaR value: tvalue; var handled: Boolean); begin value: = length (value. tostring); // end; end.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.