从窗体外部的窗体控件中查找值

Finding Values from a form control Outside Forms

我想知道是否可以从我的表单控件中获取值。通过来自我的 class 或我的 table 方法的 x++ 代码 ?

我正在遍历我的表单,我想获取所有的名称和值。我得到了名称但没有值,请帮助谢谢。

if (_formControlId)
{
    formGroupControl = _formRun.design().control(_formControlId);
}
else
{
    formGroupControl = _formRun.design();
}
// Finding children
controlCount = formGroupControl.controlCount();
for (i = 1; i <= controlCount; i++)
{
    formControl = formGroupControl.controlNum(i);
    // Fill MainTable
    if(formControl is formTabPageControl)
    {
        if(formControl.HierarchyParent()    == formControl.HierarchyParent("TabHeader"))
        {
            mainTopicId++;
            GloDataMainTopics.Topic     = formControl.labeltext();
            GloDataMainTopics.TopicId   = int2str(mainTopicId);
            GloDataMainTopics.insert();

            newParentTopicId = GloDataMainTopics.TopicId;
        }
    }
    // Fill SubTable
    if(formControl is formGroupControl)
    {
        newParentTopicId = this.fillGroupControls(formControl, _parentTopicId);
    }
    if (!newParentTopicId)
        newParentTopicId = _parentTopicId;
    //Fill Lines
    if (formControl is FormStringControl    || formControl is FormReferenceGroupControl ||
        formControl is FormCheckBoxControl  || formControl is FormComboBoxControl       ||
        formControl is FormWindowControl    || formControl is FormDateControl           ||
        formControl is FormRealControl      || formControl is FormIntControl)
        {
            this.fillLineFields(formControl, newParentTopicId, j);

            /*
            this.fillTabPagePurchase(formControl, newParentTopicId);
            this.fillTabPageGeneral(formControl, newParentRecId);
            */
            //info(strFmt("MainTopics '%1', %2", formControl.name(), j ));
        }

    if (formControl.isContainer())
    {
        this.findNodes(_formRun, formControl.id(), newParentTopicId);
    }
}

是的,你可以。请记住,某些控件的值存储在 .text()valueStr() 等中而不是 .value() 中,但您会弄明白的。

Object      control;
control = formControl; // I'm assuming this is your control you're using

if (SysTest::hasMethod(control, identifierStr(text)))
{
    text = control.text();
    info(strFmt("Text found is '%1'", text));
}

if (SysTest::hasMethod(control, identifierStr(value)))
{
    value = control.value();
    info(strFmt("Value found is '%1'", value));
}

这是一篇博客 post 我写的这篇博客展示了如何递归处理所有表单控件。您可以采用内部方法并将其放在表单的方法上,然后在 运行 时间调用它,只需添加额外的 SysTest:: 块,它应该为您提供每个概念的快速工作证明控制表格和 value/text/etc.

http://www.alexondax.com/2014/05/how-to-use-recursion-to-loop-over-form.html