如何在Dialog中添加checkBox并获取值?
How to add checkBox in Dialog and get value?
我想在 Dialog 中添加一个 CheckBox。
我使用了这个代码:
Dialog dialog;
DialogField dialogField;
NoYesId checkValue;
;
dialog = new Dialog("New dialog with checkBox");
dialogField = dialog.addFieldValue(identifierStr(NoYes) , checkValue);
checkValue= dialogField.value();
dialog.run();
info(strfmt("Value %1" , checkValue));
因此,在 Debug 中,我看到变量 (checkValue) 的值始终为 NO。
在网络教程上我看到了这段代码:
dialog.addFieldValue(typeid(NoYes), NoYes::Yes, "tip");
但是我有一个错误方法类型不存在。
路在何方?
谢谢大家,
尽情享受吧!
您只能对扩展数据类型 (EDT) 使用 typeId
(AX 2009 及更早版本)或 extendedTypeStr
(AX 2012),而不是像 NoYes
这样的枚举。它可以在 NoYesId
上使用,因为它是 EDT。
dialog.addFieldValue(typeid(NoYesId), NoYes::Yes, "Check");
您必须调用 运行 才能有意义地获取值。
Dialog dialog = new Dialog("New dialog with checkBox");
NoYesId checkValue = NoYes::No;
DialogField dialogField = dialog.addFieldValue(extendedTypeStr(NoYesId), checkValue, "Check it");
if (dialog.run())
{
checkValue = dialogField.value();
info(strfmt("Value %1" , checkValue));
}
identifierStr 而不是 extendedTypeStr 为我工作(Ax 2012)
如果枚举不存在扩展数据类型,您可以使用enumStr()
,例如:
dialogField = dialog.addFieldValue(enumStr(NoYes), checkValue);
我想在 Dialog 中添加一个 CheckBox。
我使用了这个代码:
Dialog dialog;
DialogField dialogField;
NoYesId checkValue;
;
dialog = new Dialog("New dialog with checkBox");
dialogField = dialog.addFieldValue(identifierStr(NoYes) , checkValue);
checkValue= dialogField.value();
dialog.run();
info(strfmt("Value %1" , checkValue));
因此,在 Debug 中,我看到变量 (checkValue) 的值始终为 NO。
在网络教程上我看到了这段代码:
dialog.addFieldValue(typeid(NoYes), NoYes::Yes, "tip");
但是我有一个错误方法类型不存在。
路在何方? 谢谢大家,
尽情享受吧!
您只能对扩展数据类型 (EDT) 使用 typeId
(AX 2009 及更早版本)或 extendedTypeStr
(AX 2012),而不是像 NoYes
这样的枚举。它可以在 NoYesId
上使用,因为它是 EDT。
dialog.addFieldValue(typeid(NoYesId), NoYes::Yes, "Check");
您必须调用 运行 才能有意义地获取值。
Dialog dialog = new Dialog("New dialog with checkBox");
NoYesId checkValue = NoYes::No;
DialogField dialogField = dialog.addFieldValue(extendedTypeStr(NoYesId), checkValue, "Check it");
if (dialog.run())
{
checkValue = dialogField.value();
info(strfmt("Value %1" , checkValue));
}
identifierStr 而不是 extendedTypeStr 为我工作(Ax 2012)
如果枚举不存在扩展数据类型,您可以使用enumStr()
,例如:
dialogField = dialog.addFieldValue(enumStr(NoYes), checkValue);