首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按内容高度增长区段报告

按内容高度增长区段报告
EN

Stack Overflow用户
提问于 2014-11-13 05:16:23
回答 1查看 1.5K关注 0票数 0

我试图在ActiveReport的细节部分添加内容。但截面高度限制在2英寸以内。它只需要(2/0.2 = )10项。我希望这个部分随着内容的增加而增加高度,这样它就可以采用所有的项目。看来.CanGrow不起作用了。我使用的代码如下所示。

代码语言:javascript
复制
Dim lObjSecRpt As New GrapeCity.ActiveReports.SectionReport()
Dim lObjLbl As New GrapeCity.ActiveReports.SectionReportModel.Label()
Dim c As Single = 0.2F

Try

lObjSecRpt.Sections.InsertPageHF()
lObjSecRpt.Sections(0).BackColor = Color.WhiteSmoke
lObjSecRpt.Sections(0).Height = 0.0F

lObjSecRpt.Sections.Insert(1, New GrapeCity.ActiveReports.SectionReportModel.Detail())
lObjSecRpt.Sections(1).BackColor = Color.WhiteSmoke
lObjSecRpt.Sections(1).CanGrow = True

For Each dr As DataRow In mObjDtReport.Rows
    lObjLbl = New GrapeCity.ActiveReports.SectionReportModel.Label()

    lObjLbl.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Left
    lObjLbl.Font = New System.Drawing.Font("Arial", 10, FontStyle.Regular)
    lObjLbl.Location = New PointF(0.0F, c)
    lObjLbl.Height = 0.2F
    lObjLbl.Width = 1.0F
    lObjLbl.Text = CStr(dr("RptObjNam"))
    lObjSecRpt.Sections(1).Controls.Add(lObjLbl)
    c += c
Next

Me.rptViewer.LoadDocument(lObjSecRpt)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-17 04:25:47

阿玛尔

在代码中,您要做的是动态地创建节并将控件添加到节中。这就像在运行时创建一个报表布局一样。由于您只是将控件添加到detail部分,因此detail部分的format事件不会为每个控件触发,因为它不绑定到任何数据。相反,您只是在它中添加控件。您可以检查和示例动态创建报告的这里

如果希望“详细信息”部分增长以显示所有添加的控件,则需要根据其内部控件的总高度增加其高度。例如,检查下面的示例代码,它演示了如何做到这一点。您可以简单地将此代码添加到Form_Load事件以验证它。

代码语言:javascript
复制
    Dim lObjLbl As New GrapeCity.ActiveReports.SectionReportModel.Label()
Dim c As Single = 0.2F
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim rpt As New GrapeCity.ActiveReports.SectionReport
    rpt.Sections.InsertPageHF()
    rpt.Sections(0).BackColor = Color.Yellow
    rpt.Sections(0).Height = 1.0F
    rpt.Sections.Insert(1, New GrapeCity.ActiveReports.SectionReportModel.Detail())
    rpt.Sections(1).Name = "Detail"
    rpt.Sections("Detail").BackColor = Color.Gainsboro
    rpt.Sections("Detail").CanGrow = True

    Dim i As Integer
    For i = 0 To 20
        Dim lObjLbl As New GrapeCity.ActiveReports.SectionReportModel.Label()
        lObjLbl.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Left
        lObjLbl.Font = New System.Drawing.Font("Arial", 10, FontStyle.Regular)
        lObjLbl.Location = New PointF(0.0F, c)
        lObjLbl.Size = New SizeF(1.0F, 0.2F)
        lObjLbl.Text = "Record: " + i.ToString()
        lObjLbl.BackColor = Color.Aqua
        rpt.Sections("Detail").Controls.Add(lObjLbl)
        c += 0.2
    Next
    Dim height As Double = 0
    For Each control As GrapeCity.ActiveReports.SectionReportModel.ARControl In rpt.Sections("Detail").Controls
        height = height + control.Height
    Next
    rpt.Sections("Detail").Height = height
    Viewer1.LoadDocument(rpt)
End Sub

我希望这能帮到你。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26901803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档