如何在窗体的网格中从 RealEdit 获取和设置 Real 值?
How to get and set Real value from RealEdit in a Form's Grid ?
我在 Grid 中有一个 RealEdit ,我设置 autodeclaration YES.
名称是 myRealEdit ,DataSource 是 myTable 和 Field 是 myRealField.
在modified方法中我想获取值,需要做一个IF控制
如果值为 0,则更改 Filed 的值 如果值不为 0
抛出输入的值并恢复之前的值。
我在修改方法中使用了这段代码:
public boolean modified()
{
boolean ret;
real storedValue;
ret = super();
storedValue = myTable.myRealField; // there is another way to get the value ?
if (myRealEdit.valueStr() == "0")
//accept the value
if (!myRealEdit.valueStr() != "0")
{
myRealEdit.realValue(storedValue);
}
return ret;
}
如果该值不是 0(零),则不要恢复以前的值。
我必须使用其他方法吗?还有另一种方法来获得真正的价值吗?
谢谢指教,
尽情享受!!
我找到了一个可行的方法,
我使用了这个代码:
public boolean modified()
{
boolean ret;
if (myRealEdit.valueStr() == "0")
{
//accept the value
ret = super();
}
if (!myRealEdit.valueStr() != "0")
{
info("Value not permit");
// nothing to do
}
return ret;
}
这样,当且仅当我有一个值0我修改了值。
我需要在修改后的方法中获取或读取刚刚从 myRealEdit 插入的 Real 值。
如果社区有评论或插入的改进,将会提供更多信息。
由于您在回答中使用了 modified
方法,我想您想将此字段验证放在控制级别(而不是数据源或 table 级别)。
正如@Jan B. Kjeldsen 在他的评论中所建议的那样,您应该使用 validate
方法来进行此验证。 modified
方法只有当你想添加一些在字段值修改之外执行的逻辑时才使用。
validate
方法可能类似于
public boolean validate()
{
return this.realValue() == 0 && super() || checkFailed(strFmt("Value %1 is not permitted", this.realValue()));
// TODO please replace this with a Label and explain to the user why the value is not permitted and what he or she can do to resolve this
}
我在 Grid 中有一个 RealEdit ,我设置 autodeclaration YES.
名称是 myRealEdit ,DataSource 是 myTable 和 Field 是 myRealField.
在modified方法中我想获取值,需要做一个IF控制
如果值为 0,则更改 Filed 的值 如果值不为 0 抛出输入的值并恢复之前的值。
我在修改方法中使用了这段代码:
public boolean modified()
{
boolean ret;
real storedValue;
ret = super();
storedValue = myTable.myRealField; // there is another way to get the value ?
if (myRealEdit.valueStr() == "0")
//accept the value
if (!myRealEdit.valueStr() != "0")
{
myRealEdit.realValue(storedValue);
}
return ret;
}
如果该值不是 0(零),则不要恢复以前的值。
我必须使用其他方法吗?还有另一种方法来获得真正的价值吗?
谢谢指教,
尽情享受!!
我找到了一个可行的方法,
我使用了这个代码:
public boolean modified()
{
boolean ret;
if (myRealEdit.valueStr() == "0")
{
//accept the value
ret = super();
}
if (!myRealEdit.valueStr() != "0")
{
info("Value not permit");
// nothing to do
}
return ret;
}
这样,当且仅当我有一个值0我修改了值。
我需要在修改后的方法中获取或读取刚刚从 myRealEdit 插入的 Real 值。
如果社区有评论或插入的改进,将会提供更多信息。
由于您在回答中使用了 modified
方法,我想您想将此字段验证放在控制级别(而不是数据源或 table 级别)。
正如@Jan B. Kjeldsen 在他的评论中所建议的那样,您应该使用 validate
方法来进行此验证。 modified
方法只有当你想添加一些在字段值修改之外执行的逻辑时才使用。
validate
方法可能类似于
public boolean validate()
{
return this.realValue() == 0 && super() || checkFailed(strFmt("Value %1 is not permitted", this.realValue()));
// TODO please replace this with a Label and explain to the user why the value is not permitted and what he or she can do to resolve this
}