我在init和run方法中尝试了以下方法,但它不起作用:
for( i = 1 ; i <= element.form().design().controlCount() ; i++ ){ control = element.form().design().controlNum(i); switch ( control.handle() ) { case classnum(FormBuildbuttonControl): element.initbutton(control); break; case classnum(FormBuildStaticTextControl): element.initStaticText(control); break; }}
有没有办法做到这一点?
解决方法 您可以使用的代码,但它只遍历设计的顶层.您需要构建一个递归函数来遍历整个控件集,并将它放在super()之前的init方法中:voID init(){ int i; voID processControls(FormBuildControl fbc) { int j; ; if (fbc.isContainer()) { for (j = 1; j < fbc.controlCount(); j++) { //Process container,if you need to processControls(fbc.controlNum(j)); } } else { //Control is not a container,process it here. } } ; for (i = 1; i <= element.form().design().controlCount(); i++) { processControls(element.form().design().controlNum(i); } super();}
super()调用将自动初始化表单上的所有控件.初始化后,您将无法使用FormBuildControl类型对象来配置字段,因为它们已经被用于表单上.如果你需要在初始化后修改字段,你应该直接引用该字段(虽然我不确定你如何获得字段名称并通过X引用它).
而不是有条件地初始化控件,调用super()并简单地有条件地隐藏字段,或使用安全性隐藏您不希望某些人有权访问的信息.
编辑:由于您正在处理FormBuildControls,它们是预初始化的设计,因此您应该在初始processControls调用之后进行super()调用.我改变了我的例子以反映这一点.
总结以上是内存溢出为你收集整理的dynamic – AX2009遍历init中表单中的所有控件全部内容,希望文章能够帮你解决dynamic – AX2009遍历init中表单中的所有控件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)