“这个”与“元素”相对X++ 中的关键字
在 X++ 中编写代码时,有时需要引用 this.functionYouWant()
,有时需要引用 element.FunctionYouWant()
。有时两者都在范围内。我经常尝试其中一种,如果没有我想要的功能,我会尝试另一种。是否有规则解释何时使用 this
以及何时使用 element
?
When writing code in X++ you sometimes need to reference this.functionYouWant()
and sometimes it is element.FunctionYouWant()
. Sometimes both are in scope. I often try one and if the function I want isn't there I try the other. Is there a rule that explains when to use this
and when to use element
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
this
可以在任何对象中使用来引用当前对象和成员方法。MorphX 表单和报告是复合对象。
在表单中,对象集合包含在
FormRun
对象中。您可以使用element
引用来引用外部FormRun
对象中的成员。如果您的代码放置在顶层,则
this
和element
之间没有功能差异。如果您的代码放置在 FormDataSource 中,
this
将引用数据源,但element
将引用FormRun
。this
can be used in any objects to reference the current object and member methods.MorphX forms and reports are composite objects.
In forms the collection of objects is contained within a
FormRun
object. You can reference members in the outerFormRun
object by using theelement
reference.If your code is placed at the top level there are no functional difference between
this
andelement
.If your code is placed in a FormDataSource
this
will reference the datasource butelement
will reference theFormRun
.“this”只能用于指代相同的类对象,但“element”可以访问任何表单级别(如数据源级别、设计级别)的表单方法,如果方法的功能相同,我们可以使用
"This" can be used only refers to the same class objects but "element" is access the form methods into any form level(like datasouce level,design level)if the functionality of method is same we can use