取计算列值


10 楼dawugui(潇洒老乌龟)回复于 2006-08-05 21:39:26 得分 0

0150   --   数据窗口中各项指标的获取方法   
  http://www.51pb.com/viewthread.php?tid=1005&extra=page%3D6   
    
  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   =   dw_1.Describe("#"+string(i)+".name")   
     str_column_text   =   dw_1.Describe(str_column   +   "_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     
 Top

11 楼dawugui(潇洒老乌龟)回复于 2006-08-05 21:41:40 得分 0

0164   --   怎样得到计算域的值   
  http://www.51pb.com/viewthread.php?tid=1022&extra=page%3D5   
    
    对于一般类型的数据窗口,我们可以用这种办法:先为计算域取名,如“count_id”,取值过程如下(除了分组的数据窗口,一般计算域都用1):   
    long   ll_count_id     
    如果在detail区:ll_count_id   =   dw_1.getitemnumber(1,″count_id″)   
    如果在summary区:ll_count_id   =   dw_1.object.compute_1[1]     
    
    
    而对于复合报表,须先用GetChild()函数得到其中的report,再取此report中计算域的值。假设此   report   name   为“report_department”(注意不要混淆report   name   与子数据窗口本身的名字),计算域名为count_id,则取值过程如下:   
    DataWindowChild   dwc_child   
    long   ll_count_id     
    dw_1.GetChild(″report_department″   
    dwc_child)   

    ll_count_id   =   dwc_child.getitemnumber(1,″count_id″) 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值