Sign in Join
Wiki copytemporary

TMultiPropertyLink: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11TMultiPropertyLink enables linking all child RTTI controls' TIObject to a single component at once.
22
33## Selecting the controls
44
55There are three methods to select the controls which should be changed by TMultiPropertyLink. This can be controlled by setting the appropriate properties. By Default all siblings e.g. on the same form are linked. Thus the properties have to be changed if you want to link controls to different objects.
66
77| Property | Meaning |
88|----|----|
99| MaintainGrandChilds | Works only if ParentControl is set. If MaintainGrandChilds is not flagged, only the direct child controls of ParentControl will be linked. If there is another control between ParentControl and the RTTI control, you need to set this flag. Example: Panel (ParentControl) \> Panel \> TTiEdit |
1010| MaintainSiblings | Link all components with the same owner. If you drop them on the form, all components and the TMultiPropertyLink have the same Owner (the form itself) regardless how you nest them e.g. in panels. |
1111| ParentControl | Link all controls which are placed on this control. |
1212| RootComponent | Link all components which are owned by this component. |
1313
1414## Example
1515
1616Create a form, drop a TEdit (name is Edit1), a TPanel (name is Panel1) and a TMultiPropertiLink (name is MultiPropertyLink1). Then drop two TTiEdit (names are TiEdit1 and TiEdit2) on the TPanel.
1717
1818Now, we'd like to display the width of Edit1 in TiEdit1, and the content of Edit1 (it's text property of Edit1) in TiEdit2.
1919
2020We can do this one by one --- setting Link.TIObject of both TiEdit1 and TiEdit2 as Edit1, and then setting their Link.TIPropertyName as "Width" and "Text" each. But as both TIEdit1 and TIEdit2 share parent and Link.TIObject, then can be put in a TMultiPropertyLink.
2121
2222Set MultiPropertyLink's properties as follows in Object Inspector.
2323
24-`    MaintainSiblings=False`\
25-`    ParentControl=Panel1`\
26-`    TIObject=Edit1`
24+```text
25+ MaintainSiblings=False
26+ ParentControl=Panel1
27+ TIObject=Edit1
28+```
2729
2830Set following properties.
2931
30-`    TIEdit1.Link.TIPropertyName='Width'`\
31-`    TIEdit2.Link.TIPropertyName='Text'`
32+```text
33+ TIEdit1.Link.TIPropertyName='Width'
34+ TIEdit2.Link.TIPropertyName='Text'
35+```
3236
3337When you run this program, you will see that both width and text of Edit1 are displayed within TTIEdits within Panel1. You can see the width of Edit1 changes if you change the width value manually by editing TiEdit1's value. You can change the text property either in the TIEdit2 of Edit1.
3438
3539> **Note:** When running the application in Lazarus, you'll probably face EPropertyError exceptions. This is caused if you have non-RTTI components within the scope of TMultiPropertyLink like panels or buttons. This exception can be ignored.
3640
3741---
3842*From the Free Pascal wiki, page "TMultiPropertyLink", as it stood on 2022-08-26 after a change by Egsuh, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history