pb dw_1中复选框选中的数据行,插入到另一个数据窗口dw_2中的代码怎么写
4个回答
展开全部
1.如果两个数据窗口结构一样的话可以用rowscopy
这个用法贴到最下面
2.如果仅复制一部分数据的就只有getitemXX,---and---setitemXX
首先for循环判断dw_1 哪些复选框是选中的(假如复选框列名为Flag,选中值为Y 未选中值为N)
int li_row
for i = 1 to dw_1.rowcount()
if dw_1.getitemstring(i,'Flag') ='Y' then
// 这里做插入到dw_2 中
li_row = dw_2.insertrow(0)
dw_2.SetFocus()
dw_2.ScrollToRow(li_row)
dw_2.selectrow(0,false)
dw_2.selectrow(li_row,true)
dw_2.SetColumn(1)
dw_2.setitem(li_row,'col_name',dw_1.getitemstring(i,'col_name'))
//跟多列可以类似写法 只需要更换Col_name即可
end if
next
.
rowscopy 用法:
Controls
DataWindow controls, DataStore objects, and child DataWindows
Syntax
dwcontrol.RowsCopy (startrow, endrow, copybuffer, targetdw, beforerow, targetbuffer )
Argument Description
dwcontrol The name of a DataWindow control, DataStore, or child DataWindow from which you want to copy rows
startrow A long whose value is the number of the first row you want to copy
endrow A long whose value is the number of the last row you want to copy
copybuffer A value of the dwBuffer enumerated data type specifying the buffer from which you want to copy the rows:?Primary!?Delete!?Filter!
targetdw The name of the DataWindow control or DataStore object to which you want to copy the rows. Targetdw can be the same DataWindow (or DataStore) or another DataWindow (or DataStore)
beforerow A long specifying the number of the row before which you want to insert the copied rows. To insert after the last row, use any value that is greater than the number of existing rows
targetbuffer A value of the dwBuffer enumerated data type specifying the target buffer for the copied rows. Values are:?Primary!?Delete!?Filter!
有不明白的可以HI我活着继续提问
这个用法贴到最下面
2.如果仅复制一部分数据的就只有getitemXX,---and---setitemXX
首先for循环判断dw_1 哪些复选框是选中的(假如复选框列名为Flag,选中值为Y 未选中值为N)
int li_row
for i = 1 to dw_1.rowcount()
if dw_1.getitemstring(i,'Flag') ='Y' then
// 这里做插入到dw_2 中
li_row = dw_2.insertrow(0)
dw_2.SetFocus()
dw_2.ScrollToRow(li_row)
dw_2.selectrow(0,false)
dw_2.selectrow(li_row,true)
dw_2.SetColumn(1)
dw_2.setitem(li_row,'col_name',dw_1.getitemstring(i,'col_name'))
//跟多列可以类似写法 只需要更换Col_name即可
end if
next
.
rowscopy 用法:
Controls
DataWindow controls, DataStore objects, and child DataWindows
Syntax
dwcontrol.RowsCopy (startrow, endrow, copybuffer, targetdw, beforerow, targetbuffer )
Argument Description
dwcontrol The name of a DataWindow control, DataStore, or child DataWindow from which you want to copy rows
startrow A long whose value is the number of the first row you want to copy
endrow A long whose value is the number of the last row you want to copy
copybuffer A value of the dwBuffer enumerated data type specifying the buffer from which you want to copy the rows:?Primary!?Delete!?Filter!
targetdw The name of the DataWindow control or DataStore object to which you want to copy the rows. Targetdw can be the same DataWindow (or DataStore) or another DataWindow (or DataStore)
beforerow A long specifying the number of the row before which you want to insert the copied rows. To insert after the last row, use any value that is greater than the number of existing rows
targetbuffer A value of the dwBuffer enumerated data type specifying the target buffer for the copied rows. Values are:?Primary!?Delete!?Filter!
有不明白的可以HI我活着继续提问
展开全部
你可以写在itemchanged事件当中。
假设复选框的字段叫sel,选中值为Y,不选为N
在事件中写
if dwo.name = 'sel' then //修改复选框的时候触发
if data = 'Y' then //选中
//如果二者数据列相同,可以使用rowscopy
//this.rowscopy(row,row, primary!, dw_2, dw_2.rowcount() + 1, primary!)
//数据不同,那么就要使用dw_2.insertrow()的方式增加行,并且setitem设置值了
long ll_row
ll_row = dw_2.insertrow(0)
dw_2.object.字段[ll_row] = this.object.字段[row]
... //一直写下去
else //取消选中,可以执行删除,假设有个id是二者关联
string ls_id
ls_id = this.object.id[row]
long ll_find
ll_find = dw_2.find("id = '" +ls_id+ "'", 1, dw_2.rowcount()) //查找dw_2中id匹配的一行
if ll_find > 0 then dw_2.deleterow(ll_find) //找到则删除
end if
end if
假设复选框的字段叫sel,选中值为Y,不选为N
在事件中写
if dwo.name = 'sel' then //修改复选框的时候触发
if data = 'Y' then //选中
//如果二者数据列相同,可以使用rowscopy
//this.rowscopy(row,row, primary!, dw_2, dw_2.rowcount() + 1, primary!)
//数据不同,那么就要使用dw_2.insertrow()的方式增加行,并且setitem设置值了
long ll_row
ll_row = dw_2.insertrow(0)
dw_2.object.字段[ll_row] = this.object.字段[row]
... //一直写下去
else //取消选中,可以执行删除,假设有个id是二者关联
string ls_id
ls_id = this.object.id[row]
long ll_find
ll_find = dw_2.find("id = '" +ls_id+ "'", 1, dw_2.rowcount()) //查找dw_2中id匹配的一行
if ll_find > 0 then dw_2.deleterow(ll_find) //找到则删除
end if
end if
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
假定checkbox列名为 ls_select
可以根据ls_select列值进行相关操作
如:显示所有选中行(选中时列值等1,非选中时为0)
过滤窗口
dw_1.SetFilter("ls_select = '1'")
dw_1.Filter()
有问题请留言:
可以根据ls_select列值进行相关操作
如:显示所有选中行(选中时列值等1,非选中时为0)
过滤窗口
dw_1.SetFilter("ls_select = '1'")
dw_1.Filter()
有问题请留言:
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
示例:
//假定dw_1中复选行为 flag char(1)
//待写入dw_2的cat字段中。
.........
.........
string ls_values //定义变量,用于存dw_1取的flag值
long ll_row
ls_values = dw_1.getitemstring(dw_getrow(),'flag') //getitemstring 取值
ll_row = dw_2.insertrow(1) //在dw_2中写入一条行
dw_2.setitem(ll_row,cat,ls_values) //在dw_2新行中写入cat字段值为dw_1中flag字段值
.........
.........
//假定dw_1中复选行为 flag char(1)
//待写入dw_2的cat字段中。
.........
.........
string ls_values //定义变量,用于存dw_1取的flag值
long ll_row
ls_values = dw_1.getitemstring(dw_getrow(),'flag') //getitemstring 取值
ll_row = dw_2.insertrow(1) //在dw_2中写入一条行
dw_2.setitem(ll_row,cat,ls_values) //在dw_2新行中写入cat字段值为dw_1中flag字段值
.........
.........
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询