我想在数据窗口上输入查询条件,然后查询,直接在这个数据窗口上显示结果

gongfar 2007-12-16 11:00:29
我想在数据窗口上输入查询条件,然后查询,直接在这个数据窗口上显示结果。
我现在的做法:设置数据窗口上所有字段的retrieval argument,在数据窗口上insertrow(0),然后在空行上输入查询条件,点击查询按钮后,在数据窗口上显示结果。清屏按钮reset 数据窗口,然后再insertrow(0)
感觉很慢,而且不太稳定。
有什么成熟的做法?
...全文
363 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jlwei888 2007-12-16
  • 打赏
  • 举报
回复
你问得基本都是基本问题
DW本身就有这个功能

dw_1.Object.DataWindow.QueryMode = yes

之后再retrieve()
dawugui 2007-12-16
  • 打赏
  • 举报
回复
5、编写用户对象的Constructor事件:
String ls_Syntax
String ls_line
IF This.DataObject = '' Then Return
//创建Footer区
IF Integer(This.Describe("DataWindow.Footer.Height") ) < 120 Then
This.Object.DataWindow.Footer.Height='120'
End IF
//在Footer区添加线
ls_line = 'Create line(band=footer ' + &
'background.mode="2" background.color="16777215"' + &
'pen.style="0" pen.width="5" pen.color="0" x1="0" y1="2" ' + &
'x2="' + String(This.Width - 100) + '" y2="2" )~r~n'
this.modify( ls_line )
//获取设计时的数据窗口语法串
ls_Syntax = This.object.DataWindow.Syntax
//添加按钮语法串
ls_Syntax = uf_addbutton( ls_Syntax )
if this.Create( ls_Syntax ) <> 1 then
MessageBox('提示信息','创建数据窗口出错', StopSign!)
End If

6、从u_dw_button继承就可以了。如下图:

图贴不上来.
dawugui 2007-12-16
  • 打赏
  • 举报
回复
数据窗口中按钮的封装

在数据库的操作中,对数据表记录的检索、添加、删除和保存等操作是最基本和最常用的,可以说这些操作是数据表的标准操作。但PB并没有提供上述封装好的按钮对象,如果每次都要来添加命令按钮并编写脚本,工作是很繁琐的,而且还不能保证界面的一致性。
在PB的数据窗口对象中,可以直接放置按钮对象,而且开发人员既可以给这些按钮制定默认的操作,也可以自己定义按钮的功能。在可以指定的默认操作中就包含了上面提到的所有数据表的基本操作,这样一来在数据窗口需要相应的按钮时,只需要加入按钮对象然后指定其功能就行了。
实际上可以利用PB面向对象的编程技术,实现一个包含标准操作按钮的数据窗口对象,这样在需要用到标准操作的时候,只需要从该对象继承即可满足基本的数据应用需求。
实现过程如下(利用PB9自带数据库,EAS Demo DB V9):
1、建立一个工作空间(workspace),取名为:dwbutton。
2、建立一个应用(application),取名为:dwbutton。
3、建立一个标准的可视用户对象,类型为:datawindow,取名为:u_dw_button。

4、定义用户对象级私有函数uf_addbutton(string as_oldsyntax) return string
//功能:修改数据窗口语法串,为其增加常用功能按钮
//入口参数:as_OldSyntax 原有数据窗口语法串
//返回值: ls_NewSyntax 修改后的语法串
//应用条件:数据窗口中有Footer区, 高度> 90的区域是按钮带区
String ls_AddButton
String ls_NewSyntax
Integer li_button_width
Integer li_button_x
//确定Button的位置参数
li_button_width = (This.Width + 20) / 10 - 40
IF li_button_width > 220 Then
li_button_width = 220
li_button_x = (This.Width - 240*10) / 2
IF li_button_x <=0 Then li_button_x = 10
Else
li_button_x = 20
End if
ls_NewSyntax = as_OldSyntax
//---------------添加按钮语法串------------------------------
//检索按钮
ls_AddButton = 'button(band=footer name=cb_retrieve text="检索" ' + &
'enabled=yes action="2" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//首页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_first text="首页" ' + &
'enabled=yes action="6" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//上页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_prior text="上页" ' + &
'enabled=yes action="5" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//下页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_next text="下页" ' + &
'enabled=yes action="4" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//末页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_last text="末页" ' + &
'enabled=yes action="7" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//添加按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_append text="添加" ' + &
'enabled=yes action="11" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//插入按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_insert text="插入" ' + &
'enabled=yes action="12" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//删除按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_delete text="删除" ' + &
'enabled=yes action="10" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//保存按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_update text="保存" ' + &
'enabled=yes action="13" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//打印按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_print text="打印" ' + &
'enabled=yes action="15" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
return ls_newsyntax
dawugui 2007-12-16
  • 打赏
  • 举报
回复
自己在窗口中放几个按钮,然后在按钮中写你需要的代码.

如果非要按你的想法:看我下面贴的东西你是否感兴趣.
jlwei888 2007-12-16
  • 打赏
  • 举报
回复
在窗口上部放几个编辑框,按钮,这样 做多简单
jlwei888 2007-12-16
  • 打赏
  • 举报
回复
那么设置显示列定义(column specification)空格,在需要检索的列的prompt列上打勾,
那么在retrieve()时,弹出检索窗口

要想又好看又实用的话,还的自己做!
gongfar 2007-12-16
  • 打赏
  • 举报
回复
dw_1.Object.DataWindow.QueryMode = yes 后,显示的行数很多,怎么才能只显示一行用于输入查询条件

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧