我使用datareport編寫一個報表,數據源採用vb的數據環境,現在想在form中通過程序來控制報表中顯示的字段,不用太複雜的手段,就想把visible改變就可.
看了以前部分人寫的程序,在自己系統中測試就是過不了,請高人看看是為什麼?代碼如下
    datareport1.Sections(1).Controls.Item("label1").Visible = True
    or
    datareport1.Sections(1).Controls("label1").Visible = True兩個都試過了, 可還是不通過, 郁悶!

解决方案 »

  1.   

    用第二个是可以的,.Sections(?)?是随你的label1是在那个节而定的report header是1
    page header是2
    detail是3
    顺序往下数
      

  2.   

    需要正确的设置你的label1所在的sectionsdatareport1.Sections(1).Controls.Item("label1").Visible = True例如
    With DataReport1
    .Sections(4).Controls("Label2").Caption = "共%P页第%p页"
    .Sections(2).Controls("label3").Caption = "打印日期:%d %t"'.Sections(3).Controls("Text1").DataMember = objrs.DataMember
    .Sections(3).Controls("Text1").DataField = "ziduan1"
    .Sections(3).Controls("Text2").DataField = "ziduan2"
    .Sections(3).Controls("Text3").DataField = "ziduan3"
    End With