首页 > 开发 > 综合 > 正文

pb用纯函数实现在数据窗口中模拟资源管理器鼠标单击动作动态排序,并显示排序箭头

2024-07-21 02:10:25
字体:
来源:转载
供稿:网友
//函数名:f_dwsort(datawindow fdw_dw,dwobject fdwo_dwo) return none
//说明:用于在数据窗口中模拟资源管理器鼠标单击动作动态排序,并显示排序箭头
//调用规则:在数据窗口控件clicked!中写入f_dwsort(this,dwo)
//参数:fdw_dw datawindow
//    fdwo_dwo dwobject
//返回值:无
//autor:xiaoluoxy萧云

string ls_clicked_pos,ls_col,ls_format,ls_tag
long ll_pos
string ls_text,ls_column[]
int li_i

ls_clicked_pos = fdwo_dwo.name
ll_pos = pos(ls_clicked_pos,'_t')

if ll_pos >0 then
//设置排序
ls_col = left(ls_clicked_pos,ll_pos -1)
ls_tag = fdwo_dwo.tag
if ls_tag = ls_col + "a"  then
fdwo_dwo.tag = ls_col + "d"
ls_format = ls_col+" a"
elseif ls_tag = ls_col + "d"  then
fdwo_dwo.tag = ls_col + "a"
ls_format = ls_col+" d"
else
fdwo_dwo.tag = ls_col + "d"
ls_format = ls_col+" a"
end if

//设置列标题
for li_i = 1 to long(fdw_dw.object.datawindow.column.count)
ls_column[li_i] = fdw_dw.describe("#" + string(li_i) + ".name") //得到列名
ls_text =  fdw_dw.describe(ls_column[li_i] + "_t.text")
if right(ls_text,2)="▽" or right(ls_text,2)="△" then
ls_text = left(ls_text,len(ls_text) - 2)
end if
fdw_dw.modify(ls_column[li_i] + "_t.text='"+ls_text + "'")
next

ls_text = fdw_dw.describe(ls_clicked_pos + ".text")
if right(ls_text,2)="▽" or right(ls_text,2)="△" then
ls_text = left(ls_text,len(ls_text) - 2)
end if
if right(ls_format,1) = 'a' then
fdw_dw.modify(ls_clicked_pos + ".text='"+ls_text + "△'")
elseif right(ls_format,1) = 'd' then
fdw_dw.modify(ls_clicked_pos + ".text='"+ls_text + "▽'")
end if
fdw_dw.setsort(ls_format)
fdw_dw.sort()
end if

//本程序在pb6.5下通过测试
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表