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