PB 實現子資料視窗相互關聯

2021-08-20 04:21:30 字數 1963 閱讀 8529

使用子資料視窗前需要主視窗是乙個下拉資料窗。

子資料視窗也就是下拉資料視窗。子資料視窗也是普通的資料視窗物件,沒有什麼特殊的地方,它的建立方法、可以使用的控制項、程式設計時可以使用的函式等,都和普通的資料視窗相同。特殊的地方只是因為它放在了父資料視窗中,需要和父視窗進行配合。

當為資料視窗中某欄位指定為下拉資料視窗編輯風格時,必須提供以下三個屬性:

a.子資料視窗名稱。

b.顯示欄位名稱:該字段中的內容顯示在父資料視窗的字段上,只是顯示。

c.資料欄位名稱:該字段中的內容要賦給父資料視窗的字段,要儲存到資料庫中。

下面用乙個省市縣資料關聯作為乙個例子說明。

//這裡是在主資料窗的clicked事件中

//定義子資料視窗名稱

datawindowchild dwc_province,dwc_city,dwc_home_city

string ls_name,ls_code,ls_comm,ls_comm_del

integer rtncode,li_row,li_count

this.accepttext()

if dwo.name = 'name' then //省

//獲得主視窗中的列名,顯示欄位名稱

rtncode = dw_province.getchild('name', dwc_province)

if rtncode = -1

then messagebox("error", "not a datawindowchild")

dwc_province.settransobject(sqlca)

dwc_province.retrieve()

//這裡是過濾資料窗條件,資料欄位名稱

dwc_province.setfilter("flag = '1' and isnull( comm )")

dwc_province.filter()

elseif dwo.name = 'comm' then //市

rtncode = dw_province.getchild('comm', dwc_city)

if rtncode = -1

then messagebox("error", "not a datawindowchild")

dwc_city.settransobject(sqlca)

dwc_city.retrieve()

ls_code = dw_province.object.name[1]

select name into :ls_name from zd_place_new where code =:ls_code using sqlca;

dwc_city.setfilter(" flag = '1' and comm like '%"+ls_name+"%' ")

dwc_city.filter()

elseif dwo.name = 'comm_del' then //縣區

rtncode = dw_province.getchild('comm_del', dwc_home_city)

if rtncode = -1

then messagebox("error", "not a datawindowchild")

dwc_home_city.settransobject(sqlca)

dwc_home_city.retrieve()

ls_comm = dw_province.object.comm[1]

select name into :ls_name from zd_place_new where code =:ls_comm using sqlca;

dwc_home_city.setfilter(" flag = '0' and comm_del like '%"+ls_name+"%' ")

dwc_home_city.filter()

endif

PB資料視窗

資料視窗小結 資料視窗進行刪除資料時 int zgxx id integer sle 3.text prepare sqlsa from delete from zgxx where id execute sqlsa using zg id2 messagebox 提示 刪除完畢 應用場景 主要注意...

PB資料視窗分頁

第一步 增加乙個計算列,此計算列必須放在detail段,expression中輸入 ceiling getrow 500 這裡500還可以用全域性函式取代,這樣可以允許使用者任意設定每頁多少行。第二步 定義分組,選擇選單rows create group.按計算列欄位分組,並一定將check box...

PB視窗居中的實現方法

在pb中,如何使開啟的視窗在螢幕中居中顯示呢?現在用得多的有以下兩種 1 直接使用pb視窗中的center屬性 pb9及以上版本才有該屬性 這種方法最為簡單,但是明眼人都可以看出問題來 視窗上下並沒有真正的居中,視窗被過分的往上抬了。2 為了解決這個問題,大多數程式中都使用自定義的函式來實現視窗居中...