求教:关于settext()的困惑
itemchanged 事件内有如下语句
dw_1.accepttext()
dw_1.settext(trim(dw_1.gettext()))
目的:检查当前输入的内容是否包括空格,如果有则去掉
但为什么以上语句执行后没有效果呢 例如我输入“ 111” 焦点转以后并没有变成我想要的“111”
很是困惑,请高人指点
[解决办法]
你自己到PB的帮助界面中看看即可知道如何处理了。在help的索引中输入settesx即可,看其中的代码例子。
我给你贴过来:
This example converts a number that the user enters in the column called credit to a negative value and sets both the item and the edit control's text to the negative number. This code is the script for the ItemChanged event. The data argument holds the newly entered value:
integer negative
IF dwo.Name = "credit" THEN
IF Integer(data) > 0 THEN
// Convert to negative if it's positive
negative = Integer(data) * -1
// Change the primary buffer value.
This.SetItem(row, "credit", negative)
// Change the value in the edit control
This.SetText(String(negative))
RETURN 1
END IF
END IF
[解决办法]
在itemchanged事件里一般是用getitemXXX()和setitem()函数
[解决办法]
应用itemchanged的参数data
在用setitem来做试试