PB数据窗口绝对技巧

更新时间:2023-12-07 07:33:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

PB数据窗口绝对技巧

1、如何让存储文件目录的列,显示图片?

选择对应的column的display as picture属性为true。

2、如何复制grid类型的所选择的行的数据到系统剪切板?

string ls_selected

ls_selected=dw_1.Object.DataWindow.Selected.Data clipbord(ls_selected)

3:如何改变GRID数据窗口列位置(新手常见)

先preview,然后在预览窗口拖动位置即可。

4、如何设置DW的底色?

在DW的editsource中改变color的值。 5、如何将Grid风格改成自由格式?

在DW的editsource中将processing=1的1改为0。

6、要新建一个表A但风格和现有表B风格一样,怎么将A表快速设置成表B风格?

复制B表C,在C表的DW中的editsource中将表名和字段名改成A表的,即可。 7、如何实现gird风格的datawindow的多栏表头?

添加text到header带区,并设置band属性为foreground保存,edit source修改tex

t的x和width属性表达式如下:

x=\integer(describe('firstcol.x')\width=\- integer(describe('firstcol.x')) +integer(describe('lastcol.width')) 8、如何过滤dddw编辑风格的显示值为指定值的记录?

dw_1.setfilter(\dw_1.filter()

9、如何设置datawindow的某一列为空?

string ls_temp[] setnull(ls_temp)

dw_1.object.columnname.primary.current=ls_temp 10、如何设置datawindow的单双行不同颜色间隔?

在detail带区的color属性表达式中写上if(mod (getrow(),2)=1 ,rgb(255,0,0),rgb(0,25

5,0)),如果是当前行以第三种颜色表示,表达式如下:if(getrow()=current(), rgb(255,0,0),if(mod(getrow(),2)=1 ,rgb(0,0,255),rgb(0,255,0))) 11、如何获取指定名称的datawindowobject?

DWObject ldwo_use,ldwo_abc ldwo_use = dw_1.Object ldwo_abc = ldwo_use._

_get_attribute(\为datawindow中text对象的名称 12、如何缩放datawindow的打印大小?

dw_1.object.datawindow.zoom=150 or dw_1.object.datawindow.zoom=75

13、如何在已过滤后的数据基础上对datawindow进行过滤?

dw_1.setfilter(dw_1.describe(\dw_1.filter()

14、如何在datawindow中显示动态时间?

建立一个计算域,表达式为string(datetime(today(),now()),'yyyy年mm月dd日 hh点

mm分ss秒'),同时设置datawindow的属性dw_1.Object.DataWindow.Timer_Interval=500

15、如何让带用title bar的datawindow控件的标题栏呈活动窗口的颜色?

外部函数定义:

funcation logn SetActiveWindow(long hwnd ) Library \datawindow控件的clicked事件代码: setactivewindow(handle(this))

16、如何设置datawindow的当前行指示图标?

在datawindow中建立一个计算列,expression为'',并将该计算列移动为datawindow

的第一个列,在datawindow控件的rowfocuschanged事件中写入代码:

SetRowFocusIndicator(hand!)或setrowfucsindicator(p_1)//p_1为窗口上的picture控

件名

17、如何通过代码打开dddw?

定义外部函数引用声明:

SUBROUTINE keybd_event( int bVk, int bScan, int dwFlags, int dwExtraInf

o) LIBRARY \

代码如下:

constant integer VK_F4 = 115

dw_1.SetFocus()

dw_1.SetColumn( \) // 设置当前dddw keybd_event( VK_F4,0,0,0 ) // 按下F4键 keybd_event( VK_F4,0,2,0 ) // 释放F4键

18、如何打印datawindow的内容到文件中?

dw_1.object.datawindow.print.fileName =\dw_1.print()

19、如何设置dddw的初始值?

dw_1.object.columnname.Initial=\

20、如何只显示不同的数据?

dw_1.filter(\and columnname<>columnname[-1]\

dw_1.filter()

21、如何让带有title bar的datawindow不可以移动?

在datawindow的自定义事件ue_nchittest(pbm_nchittest)中写入如下代码: return 1

22、如何在N-UP显示风格中建立基于第N栏中的列的计算列?

如column有两列,number和price ,并显示为两栏,则第一栏的cost计算列的expr

ession为number*price,第二栏的cost_1计算列的expression为number[1]*price[1] 23、如何清空ddlb或edit.codetable中项目?

dw_1.Object.columnname.Values=\

24、如何实现指定的column的字体旋转90度?

dw_1.object.columnname.font.Escapement =\

25、如何获取datawindow的sql代码?

可以通过以下四种方法获取sql代码: string szselect

szselect=dw_1.describe(\szselect=dw_1.describe(\szselect=dw_1.describe(\szselect=dw_1.getsqlselect()

26、如何获取datawindow对象占有的虚拟存储的容量?

使用datawindow.storage属性

举例:在datawindow控件的retrieverow事件中,写入如下代码: long lstorage

lstorage=long(dw_1.object.datawindow.storage) if lstorage>50000 then dbcancel()

27、如何连续在同一张纸打印两个数据窗口?

dw_1.object.datawindow.print.filename=\dw_2.object.datawindow.print.filename=\dw_1.print() dw_2.print()

28、如何设置datawindow分组后每个分组中的记录号?

建立一个计算列,expression为 getrow() - first(getrow() for group 1)+1

29、如何实现在datawindow中只有新增的行,才可以编辑?

在所有的column的protect属性表达式中写入以下表达式: if(isrownew(),'0','1')

30、除了循环以外,有没有更好的方法统计数据窗口中处于选中状态的行数?

一般习惯于使用循环来统计数据窗口中处于选中状态的行数,有没有更好的方法?其实此问题在应用上用处不大,讨论一下,活跃一下思维还是有好处的。

方法一: long ll_Selected

ll_Selected = long(dw_1.describe(\if(IsSelected(), 1, 0) for all)',1)\

方法二: long ll_Selected

ll_Selected = long(dw_1.describe(\for all)',1)\

方法三:

upperbound(dw_1.Object.Data.Selected)

31、怎么让PB只打印当前记录,是用Free格式制作的数据窗口! DataStore ldt_temp long ll_Row , ll_Rows ll_Rows = dw_XX.Rowcount() If ll_Rows = 0 Then GoTo the_end If ll_Rows = 1 Then

dw_XX.Print() GoTo the_end

End if

dw_XX.SetRedraw(False) ldt_temp = Create DataStore

ldt_temp.DataObject = dw_XX.DataObject ll_Row = dw_XX.GetRow()

dw_XX.RowsMove(1 , ll_Rows , Primary! , ldt_temp , 1 , Primary!) ldt_temp.RowsMove(ll_Row , ll_Row , Primary! , dw_XX , 1 , Primary!) dw_XX.Print()

dw_XX.RowsMove(1 , 1 , Primary! , ldt_temp , ll_Row , Primary!) ldt_temp.RowsMove(1 , ll_Rows , Primary! , dw_XX , 1 , Primary!) Destroy ldt_temp dw_XX.SetRedraw(True) the_end:

只用将上述脚本拷入到打印部分即可,dw_XX为被打印的free型数据窗口,该方法可

保证dw_XX中的数据在打印前后包括sort等属性均不发生任何改变,但效率较低,不宜用在数据量太大的数据窗口中,当然,考虑到打印本身速度就比较慢,所以3000行数据是可

以采用这种方法并让用户接受的。若在同一窗口上存在与dw_XX共享的grid数据窗口并且与dw_XX同时显示,则需要与dw_one一起SetRedraw()。 32、字段如何自动换行的同时且自动高度?

将数据窗口中相应列的auto horz scroll为不选中,选中autosize height;将detail

的autosize height选中。在数据窗口retrieve后调用下面函数即可:

uf_set_text(datawindow adw_content,string as_columns,boolean,ab_ignoreblank) /*************************************************************

Describe:在数据窗口adw_content中,在as_columns中包含的列中插入空格 Args:as_columns 要操作的多个列,列间用逗号隔开 *************************************************************/

if (not isvalid(adw_content)) or isnull(as_columns) or len(as_columns)<1 or isnull(ab_ignoreblank) then return -1

n_cst_string lnv_string

string ls_column[] , ls_width ,as_source,as_replaced ,ls_temp int li_upperbound , li_width , li_column , li_fontWidth, li_counter long ll_rowcount , ll_row , ll_totalstep

int li_yield

lnv_string.of_parsetoarray(as_columns,',',ls_column) li_upperbound = upperbound(ls_column) ll_rowcount = adw_content.rowcount()

if li_upperbound<1 or ll_rowcount<1 then return -1 openwithparm(w_waiting,this) ib_cancel = false iw_frame.enabled = false

ll_totalstep = ll_rowcount * li_upperbound w_waiting.uf_register(ll_totalstep) for li_column = 1 to li_upperbound

ls_width = adw_content.describe(ls_column[li_column]+\ li_width = integer(ls_width)

if ls_width='!' or ls_width='?' or li_width=0 then continue end if

//ls_temp = adw_content.describe(ls_column[li_column]+\{ = 'width' }\

//messagebox(ls_column[li_column]+\{ = 'width' }\ //return 1 li_fontwidth = 27

li_counter = li_width / li_fontWidth

for ll_row=1 to ll_rowcount

if ib_cancel then

iw_frame.enabled = true return 0

//pressed cancel button end if

as_source = adw_content.getitemstring(ll_row,ls_column[li_column]) as_replaced = uf_insertstring(as_source,li_counter,' ',false) if as_replaced<>as_source then

adw_content.setitem(ll_row,ls_column[li_column],as_replaced) end if

w_waiting.uf_stepit() next next

close(w_waiting) iw_frame.enabled = true return 1

33、如何使dw的列不可移动,不可调整列宽?

在datawindow的cilcked事件写: if row=0 then return 1 end if 34、光标跳转到数据窗口的某一行某一列

dw_1.scrolltorow(ll_row) dw_1.setcolumn(ll_column) 35、如何使光标指向每页第一行?

long ll_firstrowonpage=long(dw_1.describe(\

dw_1.scrolltorow(ll_firstrowonpage) dw_1.setrow(ll_firstrowonpage)

36、Grid的窗口如何使第一列固定不动?

①选上data OBJECT的HSplitScroll属性 ②在constructor事件中:

dw_1.Object.DataWindow.HorizontalScrollSplit=integer(dw_1.describe(\ //第一列的宽度

③在scrollhorizontal事件中: int i

if pane = 1 then

i = integer(this.OBJECT.datawindow.horizontalscrollposition2) if i < 1 or isnull(i) then return if scrollpos > 0 then

this.OBJECT.datawindow.horizontalScrollPosition = 0

end if

else

i = integer(this.Object.DataWindow.HorizontalScrollSplit) if i < 1 or isnull(i) then return if i > scrollpos then

this.OBJECT.datawindow.horizontalScrollPosition2 = i

end if

end if

37、如何禁止修改grid数据窗口列宽度

在Grid数据窗口的Clicked事件中加入: If row = 0 Then return 1

38、grid数据窗口改变列宽度事件:

event:pbm_lbuttondown,pbm_mousemvoe,pbm_lbuttonup

如果:

? pbm_lbuttondown:在数据窗口标题栏(getrow() = 0 and GetObjectAtPointer

=你的标题)按下鼠标左键,记一个标志; ? pbm_mousemvoe:鼠标移动了,在记一个标志;

? pbm_lbuttonup:这时鼠标左键up,再判断最后一列的位置是否发生变化,如果有,

写你的脚本。

39、如何判断数据窗口内容是否修改

if dw_wh.deletedcount() + dw_wh.modifiedcount() > 0 then

integer li_ret

li_ret = messagebox(\注意\数据已经被修改,是否存盘?\

ncel!) end if

40、如何得到数据窗口鼠标光标下的控件和行

建立一个自定义事件,事件号pbm_dwnmousemove,事件有参数row、dwo 41、数据窗口循环删除行,必须要从最后一行开始删除,如

for ll_row =dw_1.rowcount() to 1 step -1

//if 删除条件 then dw_1.deleterow(ll_row)

next

当然,也可以用do while加上find函数实现。

本文来源:https://www.bwwdw.com/article/297t.html

Top