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.o b j e c t.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、如何擷取指定名稱的datawindowo b j e c t?
答: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.o b j e c t.datawindow.zoom=150 or dw_1.o b j e c t.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.o b j e c t.datawindow.print.fileName ="c:\temp.prn"
dw_1.print()
19、如何設定dddw的初始值?
答:dw_1.o b j e c t.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.o b j e c t.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.o b j e c t.datawindow.storage)
if lstorage>50000 then dbcancel()
28、如何連續在同一張紙列印兩個資料視窗?
答:dw_1.o b j e c t.datawindow.print.filename="temp.prn"
dw_2.o b j e c t.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
43:如何禁止修改grid資料視窗列寬度
答:在Grid資料視窗的Clicked事件中加入:
If row = 0 Then return 1
44:grid資料視窗改變列寬度事件:
event:pbm_lbuttondown,pbm_mousemvoe,pbm_lbuttonup
如果:
pbm_lbuttondown: 在資料視窗标題欄(getrow() = 0 and GetObjectAtPointer =你的标題)按下滑鼠左鍵,記一個标志;
pbm_mousemvoe: 滑鼠移動了,在記一個标志;
pbm_lbuttonup: 這時滑鼠左鍵up,再判斷最後一列的位置是否發生變化,如果有,寫你的腳本。
45:如何判斷資料視窗内容是否修改
if dw_wh.deletedcount() + dw_wh.modifiedcount() > 0 then
integer li_ret
li_ret = messagebox("注意","資料已經被修改,是否存盤?",Question!,YesNoCancel!)
46:如何得到資料視窗滑鼠光标下的控件和行
建立一個自定義事件,事件号pbm_dwnmousemove, 事件有參數row、dwo
47:如何改變GRID資料視窗列位置(新手常見)
先preview,然後在預覽視窗拖動位置即可。