Dim sect, ctl
For Each sect In printaddpsd.Sections
debug.Print "Section",sect.Name                                       For Each ctl In sect.controls 
      Debug.Print , ctl.Name, ctl.Caption   ', ctl.Index ', ctl.Caption   '遍历打印报表的各段及各段的控件
   Next ctl
Next sect
然后再具体设置
printaddpsd.Sections(2).Controls.Item(3).Caption = Text2.Text

解决方案 »

  1.   

    楼上 我试了
    Dim sect, ctl
    For Each sect In datareport1.Sections
        Debug.Print "Section", sect.Name
            For Each ctl In sect.Controls
                Debug.Print ,ctl.Name, ctl.Caption ', ctl.Index ', ctl.Caption   '遍历打印报表的各段及各段的控件
            Next ctl
    Next sect运行时提示:debug.print ,crl.name,ctl.caption这行,无效的属性或方法,
    加入DRgrzz.Sections(1).Controls ("label4"), Caption = "a"后
    提示后加入行controls处提示属性的使用无效!
      

  2.   

    好了,这个问题我搞定了,DRgrzz.Sections(1).Controls ("label4"), Caption = "a"这里用DRgrzz.Sections("section1").Controls ("label4"), Caption = "a"就好使,不知为什么!
    不过,我又遇到了又一个问题,我在用datareport中的image,代码如下:DRgrzz.Sections("section1").Controls("Image1").Picture = LoadPicture("c:\aa.jpg"),结果运行后告诉我“对象不支持该属性或方法”,image支持动态加载图片呀,在datareport中不行吗?那什么报表可以动态加载图片,具体该怎么做呢?请大虾们知道!谢谢
      

  3.   

    Sections("section1").并不意味着它就是该collection里面的第一号元素呀!2。你说得image是指的作为普通控件的image吧!
    datareport的控件是有自己的一套做法的
      

  4.   

    那datareport中的image怎么动态的加载图片呢