| 
1、如何让存储文件目录的列,显示图片?
×
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册 
  
 答:选择对应的column的display as picture属性为true
 
 2、如何复制grid类型的所选择的行的数据到系统剪切板?
 
 答:string ls_selected
 
 ls_selected=dw_1.Object.DataWindow.Selected.Data
 
 clipbord(ls_selected)
 
 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 修改text的x和width属性表达式如下:
 
 x="100~t integer(describe('firstcol.x')" width="100~tinteger(describe('lastcol.x')) - integer(describe('firstcol.x')) +integer(describe('lastcol.width'))
 
 8、如何过滤dddw编辑风格的显示值为指定值的记录?
 
 答:dw_1.setfilter("lookupdisplay('column_name')='"+ls_display_value_your+"'")
 
 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,255,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("t_1",FALSE)//t_1为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("datawindow.table.filter")+your_join+your_new_filter)
 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 "user32.dll"
 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 dwExtraInfo) LIBRARY "user32.dll"
 代码如下: [constant integer VK_F4 = 115
 dw_1.SetFocus()
 dw_1.SetColumn( "dept_head_id" ) //设置当前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 ="c:\temp.prn"
 dw_1.print()
 
 19、如何设置dddw的初始值?
 答:dw_1.object.columnname.Initial="your_initial_value"
 
 20、如何只显示不同的数据?
 答:dw_1.filter("isnull(columnname[-1]) 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计算列的expression为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 ="900"
 
 25、如何获取datawindow的sql代码?
 答: 可以通过以下四种方法获取sql代码:
 string szselect
 szselect=dw_1.describe("datawindow.table.select")
 szselect=dw_1.describe("datawindow.table.sqlselect")
 szselect=dw_1.describe("datawindow.table.select.attribute")
 szselect=dw_1.getsqlselect()
 
 27、如何获取datawindow对象占有的虚拟存储的容量?
 答:使用datawindow.storage属性
 举例:在datawindow控件的retrieverow事件中,写如如下代码:
 long lstorage
 lstorage=long(dw_1.object.datawindow.storage)
 if lstorage>50000 then dbcancel()
 
 28、如何连续在同一张纸打印两个数据窗口?
 答:dw_1.object.datawindow.print.filename="temp.prn"
 dw_2.object.datawindow.print.filename="temp.prn"
 dw_1.print()
 dw_2.print()
 
 29、如何设置datawindow分组后每个分组中的记录号?
 答:建立一个计算列,expression为 getrow() - first(getrow() for group 1)+1
 
 30、如何实现在datawindow中只有新增的行,才可以编辑?
 答:在所有的column的protect属性表达式中写入以下表达式:
 if(isrownew(),'0','1')
 
 31、除了循环以外,有没有更好的方法统计数据窗口中处于选中状态的行数?
 一般习惯于使用循环来统计数据窗口中处于选中状态的行数,有没有更好的方法?其实此问题在应用上用处不大,讨论一下,活跃一下思维还是有好处的。
 方法一: long ll_Selected ll_Selected = long(dw_1.describe("evaluate('sum( if(IsSelected(), 1, 0) for all)',1)"))
 方法二: long ll_Selected ll_Selected = long(dw_1.describe("evaluate('count(IsSelected() for all)',1)"))
 方法三:upperbound(dw_1.Object.Data.Selected)
 
 32、问:怎么让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()
 
 38、字段如何自动换行的同时且自动高度?
 答:将数据窗口中相应列的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]+".width") 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]+".Font.property { = 'width' }") //messagebox(ls_column[li_column]+".Font.property { = 'width' }",ls_temp) //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
 
 39、如何使dw的列不可移动,不可调整列宽?
 答:在datawindow的cilcked事件写 if row=0 then return 1 end if
 
 40.光标跳转到数据窗口的某一行某一列
 dw_1.scrolltorow(ll_row) dw_1.setcolumn(ll_column)
 
 41 如何使光标指向每页第一行?
 long ll_firstrowonpage=long(dw_1.describe("datawindow.firstrowonpage"))
 dw_1.scrolltorow(ll_firstrowonpage)
 dw_1.setrow(ll_firstrowonpage)
 
 42. Grid的窗口如何使第一列固定不动?
 ①选上data OBJECT的HSplitScroll属性 ②在constructor事件中: dw_1.Object.DataWindow.HorizontalScrollSplit=integer(dw_1.describe("#1.width")) //第一列的宽度 ③在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
 |