dw_1.object.pt_price.visible = 1
以上的语句,如果dw_1里面pt_price存在,则这写是没有问题,
但是如果pt_price这个栏位不存在,则PB肯定报错,崩溃。
所以想在这条语句之前加个判断,
if 存在 then
想请教一下,如果来判断这个. 除判断栏位,判断 计算列, text ,图片控制,button等。
在此先感谢了。
------解决方案--------------------
遍历数据窗口中所有对象
string ls_msg
string ls_datatype
string ls_value,ls_tag
string ls_objects
String ls_obj[], ls_Obj_Band[]
long li_pos, li_i
ls_Objects = dw_1.Describe("datawindow.objects")
ls_Objects += '~t'
DO While ( Pos( ls_Objects, "~t" ) > 0)
li_i ++
li_pos = Pos( ls_Objects, "~t" )
ls_obj[li_i] = Left( ls_Objects, li_pos - 1 )
ls_Objects = Right( ls_Objects, Len(ls_Objects) - li_pos)
if dw_1.describe(ls_obj[li_i]+".band") = "detail" then
if dw_1.describe(ls_obj[li_i]+".type") = "column" or dw_1.describe(ls_obj[li_i]+".type") = "compute" then
ls_tag = dw_1.describe(ls_obj[li_i]+".tag")
if isnull(ls_tag) or ls_tag = "" then continue //tag为空则继续
ls_datatype = dw_1.describe(ls_obj[li_i]+".ColType")
choose case left(ls_datatype,4)
case "char"
ls_value = dw_1.getitemstring(1,ls_obj[li_i])
case "long"
ls_value = string(dw_1.getitemnumber(1,ls_obj[li_i]))
case "deci"
ls_value = string(dw_1.getitemdecimal(1,ls_obj[li_i]))
case "date"