1. 程式人生 > >PB資料視窗中資料來源的各項控制元件的獲取方法

PB資料視窗中資料來源的各項控制元件的獲取方法

1、得到當前滑鼠所指物件所在的帶區

  string str_band

  str_band=GetBandAtPointer() //得到當前滑鼠所指物件所在的帶區

  str_band=left(str_band,(pos(str_band,'~t') - 1))//得到"header"、"detail"等

  if str_band<>'header' then return //單擊非頭區,退出

2、得到滑鼠指向的列物件名

  str_object=GetObjectAtPointer() //得到當前滑鼠所指物件名

  str_object=left(str_object,(pos(str_object,'~t') - 1))

  //得到列物件名(預設為列名_t為列標題)

  str_column=left(str_object,(len(str_title) - 2))

  //判斷該名稱是否為列名字

  if this.describe(str_column+".band")='!' then return //非是列名,即列標題不是按正常規律起名的。

3、得到當前行、列,總行、列 //this 針對資料視窗而言

  li_col = this.GetColumn()

  li_ColCount = long(describe(this,"datawindow.column.count"))

  ll_row = this.GetRow()

  ll_RowCount = this.RowCount()

  //設定當前行、列

  scrolltorow(this,ll_Row)

  setrow(this,ll_Row)

  setcolumn(this,li_col)

  this.SetFocus()

4、得到所有列標題

  ll_colnum = Long(dw_1.object.datawindow.column.count)

  for i = 1 to ll_colnum

   //得到標題頭的名字

   ls_colname = dw_1.describe('#' + string(i) + ".name") + "_t"

   ls_value = dw_1.describe(ls_colname + ".text")

  next

5、如何用程式碼取得資料視窗彙總帶計算列的值?  

  String ls_value

  ls_value = dw_1.Describe("Evaluate("'compute_1',1)")

  //如果是數值型,要轉換。

6、取得單擊的列標題、列名、資料庫欄位名

  string ls_dwo

  long ll_pos

  string ls_type

  string ls_title

  string ls_column

  string ls_dbname

  if Not KeyDown(KeyControl!) then return

  ls_dwo = dwo.Name

  if trim(ls_dwo) = '' or isnull(ls_dwo) then return

  ls_type = This.describe(ls_dwo + '.type')

  if ls_type = 'column' then

   ls_title = This.describe(ls_dwo + '_t.text')//標題

   ls_column = This.describe(ls_dwo + '.Name') //資料視窗列名

   ls_dbname = This.describe(ls_dwo + '.dbname') //資料庫中欄位名

   messagebox('資訊', '標 題 文 本 :' + ls_title + &

   '~r~n資料視窗列名 :' + ls_column + &

   '~r~n資料庫中欄位名:' + ls_dbname )

  end if

7、視窗為w_gcde內,放入一個DW_1,如何得到dw_1內的某列值yuonghu_id列的內容

  long lng_column_count

  integer i

  string str_column[] //列名

  string str_column_text[]  //text的名字

  //得到資料視窗的總列數

  lng_column_count = long(dw_1.Describe("DataWindow.Column.Count"))

  //迴圈依次讀取

  for i = 1 to lng_column_count

   str_column[i] = dw_1.Describe("#"+string(i)+".name")

   str_column_text[i] = dw_1.Describe(str_column[i] + "_t.text")

  next

8、定義要列印的頁碼

  dw_1.Modify("DataWindow.Print.Page.Range='"+sle_1.text+"'")

  dw_1.print()

9、取到當前是第幾頁

  dw_1.describe("evaluate('page()',"+string(dw_1.getrow())+")")

  //注意返回值是STRING型的

10、每15行統計一次

  在 summary 欄中寫 ceiling(Getrow()/15)

11、如何判斷當前行是不是當前頁中的最後一行

  if dw_1.getrow()=long(dw_1.describe("datawindow.lastrowonpage")) then

  else

  end if