PB 两个DataWindow之间复制某一行数据
两个dw之间复制某一行数据
方法一:rowscopy(),只限于列名、顺序、列数都相同的两个dw
方法二:当遇到列名、顺序、列数不全部相同的两个dw唉这个就麻烦了,需要2个dw,分别为dw_1、dw_2,且dw_2中必定包含dw_1中所有列。上代码:
//-------------------------------------------------------------------------// //把dw_1中的某一行全部复制到idw_requestor,用于实时更新单据管理数据窗口内容// //-------------------------------------------------------------------------// Long ll_column_count,ll_i String ls_column,ls_column_type,ls_tag idw_requestor.InsertRow(0) ll_column_count = Long(dw_1.Describe("DataWindow.Column.Count")) //总列数 idw_requestor.SetRedraw(false) For ll_i = 1 TO ll_column_count ls_column = dw_1.Describe("#"+String(ll_i)+".Name") //列名 If ls_column = '?' OR ls_column = '!' OR IsNull(ls_column) OR ls_tag = "1" Then Continue ls_column_type = lower(dw_1.Describe(ls_column + ".coltype")) //列名对应类型 //把这个dw_1的数据复制给另一个dw choose case left(ls_column_type,4) case "char" string ls_value ls_value = dw_1.getitemstring(dw_1.rowcount(),ls_column) idw_requestor.setitem(idw_requestor.rowcount(),ls_column,ls_value) case "date" datetime ld_value ld_value = dw_1.getitemdatetime(dw_1.rowcount(),ls_column) idw_requestor.setitem(idw_requestor.rowcount(),ls_column,ld_value) case "deci" decimal ldec_value ldec_value = dw_1.getitemdecimal(dw_1.rowcount(),ls_column) idw_requestor.setitem(idw_requestor.rowcount(),ls_column,ldec_value) case "long" long ll_value ll_value = dw_1.getitemnumber(dw_1.rowcount(),ls_column) idw_requestor.setitem(idw_requestor.rowcount(),ls_column,ll_value) case "numb" decimal ldec_value ldec_value= dw_1.getitemnumber(dw_1.rowcount(),ls_column) idw_requestor.setitem(idw_requestor.rowcount(),ls_column,ldec_value) end choose Next idw_requestor.SetRedraw(TRUE)