資料視窗常用技巧

來源:互聯網
上載者:User

資料視窗常用技巧
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:資料視窗中如何?用左右箭頭實現焦點切換(tab ,shift+tab)在26樓

44:如何禁止修改grid資料視窗列寬度
答:在Grid資料視窗的Clicked事件中加入:
        If row = 0 Then return 1

45:grid資料視窗改變列寬度事件:
event:pbm_lbuttondown,pbm_mousemvoe,pbm_lbuttonup
如果:
pbm_lbuttondown: 在資料視窗標題列(getrow() = 0 and GetObjectAtPointer =你的標題)按下滑鼠左鍵,記一個標誌;
pbm_mousemvoe: 滑鼠移動了,在記一個標誌;
pbm_lbuttonup: 這時滑鼠左鍵up,再判斷最後一列的位置是否發生變化,如果有,寫你的指令碼。

46:如何判斷資料視窗內容是否修改
if dw_wh.deletedcount() + dw_wh.modifiedcount() > 0 then
integer li_ret
li_ret = messagebox("注意","資料已經被修改,是否存檔?",Question!,YesNoCancel!)

43-46技巧來自天新網 http://dev.21tx.com

47:如何得到資料視窗滑鼠游標下的控制項和行
   建立一個自訂事件,事件號pbm_dwnmousemove,   事件有參數row、dwo

48:如何改變GRID資料視窗列位置(新手常見)
先preview,然後在預覽視窗拖動位置即可。

070411更新

49:資料視窗迴圈刪除行,必須要從最後一行開始刪除,如
for ll_row =dw_1.rowcount() to 1 step -1
//if 刪除條件 then
dw_1.deleterow(ll_row)
next
當然,也可以用do while 加上 find函數實現
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.