datawindow 检验表达式

本文探讨了修改检验表达式后需重新打开数据窗口的原因,解释了如何正确使用gettext()函数获取当前列值,并介绍了条件表达式支持的全局函数及触发itemerror事件的机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

检验表达式问题

修改检验表达式后要重新打开数据窗口(有时不能即时反应过来,还认为是以前的表达式,建议关闭后再重新打开)

条件表达式 支持全局函数 可以使用列做为表达式的一部分
但注意取当前列的值必须用gettext()来取,因为在验证没有通过之前
控件中还是以前的值,通过之后才是录入的值(校验通过后才接受输入值,表达式未通过将触发itemerror事件)

解读以下PB9.0代码,并列出可视化流程, //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,1) // //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,3)blue //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,4)WHITE //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,5)LIGHTER GRAY //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,6)LIGHT GRAY //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,7)LIGHT YELLOW //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,8)LIGHT PINK //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,9)LIGHT GREEN //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,10)LIGHT ORANGE //dw_1.of_setrfi(dw_1,0) //dw_1.of_setrfi(dw_1,11)LIGHT BLUE string ls_h, ls_err, ls_msg, ls_mod, ls_obj string ls_bg_colour long ll_width ll_width = Long(adw.Object.DataWindow.HorizontalScrollMaximum) //SetRowFocusIndicator的类型码 CHOOSE CASE ai_rfi_cd CASE 0 //没有RowFocusIndicator adw.SetRowFocusIndicator(Off!) //关闭以前的RowFocusIndicator //命名 “rf_rect” ls_obj = adw.Object.DataWindow.Objects if Pos(ls_obj, “rf_rect”) > 0 then ls_mod = “destroy rf_rect” ls_err = adw.Modify(ls_mod) if ls_err <> “” then ls_err = “Modify Error:” + ls_err PopulateError(-1, ls_err) goto lbl_err end if end if CASE 1 adw.SetRowFocusIndicator(Hand!) CASE 2 adw.SetRowFocusIndicator(FocusRect!) CASE 3 to 11 CHOOSE CASE ai_rfi_cd CASE 3 ls_bg_colour = string(RGB(0, 0,192)) //WHITE CASE 4 ls_bg_colour = string(RGB(255, 255, 255)) //WHITE CASE 5 ls_bg_colour = string(RGB(217, 217, 217)) //LIGHTER GRAY CASE 6 ls_bg_colour = string(RGB(192, 192, 192)) //LIGHT GRAY CASE 7 ls_bg_colour = string(RGB(255, 255, 200)) //LIGHT YELLOW CASE 8 ls_bg_colour = string(RGB(255, 179, 217)) //LIGHT PINK CASE 9 ls_bg_colour = string(RGB(140, 200, 200)) //LIGHT GREEN CASE 10 ls_bg_colour = string(RGB(255, 211, 168)) //LIGHT ORANGE CASE 11 ls_bg_colour = string(RGB(0, 192, 255)) //LIGHT BLUE END CHOOSE ll_width += adw.width //创建Rectangle的语句 ls_mod = “Create Rectangle(band=detail” + & " x=‘" + string(adw.X) + "’" +& " y=‘0’" +& " height=‘80~t if(1=1, RowHeight(), 80)’" +& " width=‘" + string(ll_width) + "’" +& " name=rf_rect " +& " visible=‘1~t if(currentrow() = getrow(), 1, 0)’" +& " brush.hatch=‘6’" + & " brush.color=‘" + ls_bg_colour + "’" +& " pen.style=‘0’" +& " pen.width=‘5’" +& " pen.color=‘" + string(RGB(0, 0, 0)) + "’" +& " background.mode=‘2’" +& " background.color=‘0’" +& “)” CASE 12 if adw.VscrollBar then ll_width += adw.width - 130 else ll_width += adw.width - 20 end if // ls_mod = “create text(band=Detail” +& " color=‘0’" +& " border=‘6’" +& " x=‘" + string(adw.X + 10) + "’" +& " y=‘0’" +& " height=‘80~t if(1=1, RowHeight() - 5, 80)’" +& " width=‘" + string(ll_width) + "’" +& " text=‘’" +& " name=rf_rect" +& " visible=‘1~t if(currentrow() = getrow(), 1, 0)’" +& " background.mode=‘2’" +& " background.color=‘12632256’" +& " )" CASE ELSE ls_err = “Illegal Option: " + String(ai_rfi_cd) + " !” PopulateError(-1, ls_err) goto lbl_err END CHOOSE CHOOSE CASE ai_rfi_cd CASE 3 to 12 ls_err = adw.Modify(ls_mod) if ls_err <> “” then ls_err = “Modify Error:” + ls_err PopulateError(-1, ls_err) goto lbl_err end if if adw.SetPosition(“rf_rect”, “detail”, FALSE) <> 1 then ls_err = “SetPosition Error.” PopulateError(-1, ls_err) goto lbl_err end if END CHOOSE return true //------------------------------------------------------------------- lbl_err: ls_msg = error.Text + ". " +& “错误/信息 错误号.=” + String(error.Number) + “; ~r~n” +& “窗体/菜单=” + error.WindowMenu + “; ~r~n” +& “对象=” + error.Object + “; ~r~n” +& “对象事件=” + error.Object + “; ~r~n” +& “错误行号=” + String(error.Line) + “.” MessageBox(“错误:”, ls_msg, Exclamation!) return false
03-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值