我想在程序中,修改report1的Region1里面的band1中的Title的text属性,该怎么办,我应该在Delphi中的哪个方法或者属性获取rave中的report1组件,并访问report1中的各个组件。。
请大家给点提示,我对于rave的工作机制好象不太熟悉,谢谢。。
我只有60分了

解决方案 »

  1.   

    RvProject1.SelectReport('Report1', False);
     RvProject1.SetParam('text', trim(WH1.text));
      

  2.   

    longwycn((理想0769) ---要做DBA) :首先谢谢你的参与,我接触Delphi不久,对报表更是没几天,有些东西没有头绪,无从下手。
    我的问题是这样的,我要打印一张成绩表,格式:
    学号,班号,姓名,语文,数学...,总分,平均分,排名
    0001  01   **    80    90.5 .. 340.5  80.5  1
    0002  02   **    70    60  ... 300    70.4  2
    ...
    这张成绩表,除了‘学号’,‘班号’,‘姓名’字段是固定不会变外,其他的字段都可能会变:因为考试的科目不会固定,如果没考语文,那么‘语文’字段就没有了,在程序中我通过ADOQuery的sql语句实现了。
    但现在要报表,字段不是固定的,所以在Rave中的DataView和report的DataBand中都不能添加字段,我必须要在Delphi的程序中动态的把ADOQuery中的字段添加到report中去,并打印输出该在哪个控件的哪个事件用什么方法实现我这种要求呀
    我手上没有资料,没点头绪。。请大家帮帮忙,非常感谢。!
      

  3.   

    这个问题我也遇到过,用第三方控件report machine可以让用户自己设计报表,不过界面非常复杂~~
      

  4.   

    Devillyd(ξ赤 影ξ) :有没有更好的方法?
    我是这样想的,虽然成绩表中的科目字段可能会变,但在打引某次考试的成绩时,成绩表是固定的,科目字段也定了,这样可以通过ADOQuery.fields[index].fieldname取的字段名,通过ADOQuery.fields[index].value可以取的其值,所以,如果能通过一个事件,把这些字段名和字段值分别添加到report中的相关Band和dataBand中去,不就行了吗?
    不知道可不可以?我不知道在Delphi中的什么事件通过什么控件的什么方法获取report中的band和dataBand组件,以及如何动态添加字段和字段值
    大家难道没有遇到过对sql查询结果在程序中进行报表设置吗?遇到过的给点提示呀谢谢
      

  5.   

    如果你能看懂的话:
    procedure THPBill.rvCreateAndInitRaveField(DBCtrlField:TField;rvFieldParent:TRaveDataView);
    begin
      case DBCtrlField.DataType of
        ftString:
          with TRaveStringField(TRaveStringField.Create(rvFieldParent)) do
            begin
              Parent:=rvFieldParent;
              FieldName:=DBCtrlField.FieldName;
            end;
        ftFloat,ftCurrency,ftADT:
          with TRaveFloatField(TRaveFloatField.Create(rvFieldParent)) do
            begin
              Parent:=rvFieldParent;
              FieldName:=DBCtrlField.FieldName;
              DisplayFormat:=TFloatField(DBCtrlField).DisplayFormat;
            end;
        ftInteger,ftWord,ftSmallint,ftLargeint:
        //ftWord is type of Integer,in SQL DataBase is tinyint type
           with TRaveIntegerField(TRaveIntegerField.Create(rvFieldParent)) do
            begin
              Parent:=rvFieldParent;
              FieldName:=DBCtrlField.FieldName;
              DisplayFormat:=TFloatField(DBCtrlField).DisplayFormat;
            end;
        ftBCD://合计栏等计算Field,不能用Float
          with TRaveBCDField(TRaveBCDField.Create(rvFieldParent)) do
            begin
              Parent:=rvFieldParent;
              FieldName:=DBCtrlField.FieldName;
              DisplayFormat:=TFloatField(DBCtrlField).DisplayFormat;
            end;
        ftDateTime:
          with TRaveDateTimeField(TRaveDateTimeField.Create(rvFieldParent)) do
            begin
              Parent:=rvFieldParent;
              FieldName:=DBCtrlField.FieldName;
            end;
        ftBoolean:
          with TRaveBooleanField(TRaveBooleanField.Create(rvFieldParent)) do
            begin
              Parent:=rvFieldParent;
              FieldName:=DBCtrlField.FieldName;
            end;
        else
          raise Exception.Create('创建Rave数据类型错误:数据库中字段'+DBCtrlField.FieldName+'超出Rave的类型'
                                    +',参见D调试模式中Error:DataView:FieldName');
      end;
    end;
      

  6.   

    Devillyd(ξ赤 影ξ) 谢谢
    这段代码,我等下慢慢看,,另外我还有个问题:
    我在delphi中,可以申明TRaveText,TRavePage变量,但却不能声明TRaveDataBand,TRaveBand以及TRaveRegin变量。
    还有,我可以用FindRaveComponent('report1.mainpage',nil)取的report中的page,但用FindRaveComponent('report1.mainpage.dataview1region.band1.Text1',nil)获取哪个text1,却有错误,提示为,冲突。。
    怎么回事?
      

  7.   

    上面的我想我知道怎么回事了,是我没有use rvcsrpt的缘故
      

  8.   

    Devillyd(ξ赤 影ξ) :
    你提供的代码,是根据Delphi中某个表格的字段,往rave报表中的DataView动态添加字段。
    那添加后,又该怎么办?我的意思是说,要不要处理Page中的Band和DataBand?以便打印显示字段名和字段值?
    麻烦你进一步说明。。我被这个报表卡在这儿两天了找不到资料又没有帮组,快憋死了。。