Introduction to Delphi xe2 firemonkey (28)-Data Binding: tbindingslist: Expression Function Test: selectedtext (), checkedstate ()

Source: Internet
Author: User
Example concept: Use label1 to display the listbox1 option, and use label2 to display the checkbox1 status.

1. place controls: label1, label2, listbox1, checkbox1, bindingslist1, and bindscope1;
2. Activate the onclick event of listbox1 and the default event of the form.

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, Data. BIND. components, FMX. layouts, FMX. listBox; Type tform1 = Class (tform) label1: tlabel; label2: tlabel; listbox1: tlistbox; checkbox1: tcheckbox; bindingslist1: success; identifier: tbindscope; Procedure formcreate (Sender: tobject); Procedure listbox1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. FMX} uses FMX. BIND. editors; // when expression functions are used for selectedtext, selecteditem, and checkedstate, the supported units are procedure tform1.formcreate (Sender: tobject); var I: integer; begin for I: = 1 to 9 do listbox1.items. add ('item _ '+ inttostr (I); with tbindexpression. create (bindingslist1) Do begin controlcomponent: = label1; controlexpression: = 'text'; sourcecomponent: = bindscope1; sourceexpression: = 'selectedtext (listbox1 )'; // same as the next line // sourceexpression: = 'listbox1. selected. text'; active: = true; end; with tbindexpression. create (bindingslist1) Do begin controlcomponent: = label2; controlexpression: = 'text'; sourcecomponent: = bindscope1; sourceexpression: = 'checkedstate (checkbox1) '; // checked: 'true'; unchecked: 'false'; grayed: ''// sourceexpression: = 'checkbox1. ischecked '; // in this example, this is equivalent to the previous line Active: = true; end; checkbox1.onclick: = listbox1.onclick; end; Procedure tform1.listbox1click (Sender: tobject ); begin bindingslist1.y y (sender, ''); 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.