数据窗口技巧

来源:互联网 发布:javascript可以看的书 编辑:程序博客网 时间:2024/05/05 05:17
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_o b j e c t=GetObjectAtPointer() //得到当前鼠标所指对象名
str_o b j e c t=left(str_o b j e c t,(pos(str_o b j e c t,'~t') - 1))
//得到列对象名(默认为列名_t为列标题)
str_column=left(str_o b j e c t,(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.o b j e c t.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