This is a migrated thread and some comments may be shown as answers.

Problem with programatically added panel controls with children

1 Answer 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ticket Solutions Account
Top achievements
Rank 1
Ticket Solutions Account asked on 10 Aug 2010, 04:05 AM

Hi,

I'm trying to add a panel programatically to a report. I have a class that programattically generates a bunch of controls, then puts them in a panel, then returns the panel as an array of ReportItemBase with length of 1.

When i do this it appears to put a page break in after each panel.

I've tried altering the class to return just the controls without the panel parent and it works fine.

This is a problem though, because the reason I'm using a panel to put them inside of, is that I need each set of controls to make sure they are on the same page.

Here's the method

I've got commented out code line around where i've changed things to make it work. I've also tried two methods to add the controls to the panel, one is using the parent property and the other using the items.addrange, both work, but both cause the page break after each panel.


Public Overrides Function RenderControlSet(Optional ByRef parent As Telerik.Reporting.Panel = Nothing) As Telerik.Reporting.ReportItemBase()
    'MyBase.RenderControlSet()
    Dim questionDetail As DataTable = _questionDetail
    Dim question As DataRow = _question
    Dim cbl1 As ReportsCheckBoxList = New ReportsCheckBoxList
      
    Dim pnl As New Telerik.Reporting.Panel
    pnl.Top = New Drawing.Unit(StartTop, UnitType.Cm)
    pnl.KeepTogether = True
    pnl.StyleName = "stylePnl"
    'pnl.Style.BorderColor=
    If Not parent Is Nothing Then
        pnl.Parent = parent
    End If
    Dim t1 As New Telerik.Reporting.TextBox
    Dim TextBoxWidth As Drawing.Unit = New Drawing.Unit(14 - LeftMargin, UnitType.Cm)
    Dim TextBoxHeight As Drawing.Unit = New Drawing.Unit(0.6, UnitType.Cm)
    t1.Width = TextBoxWidth
    t1.Height = TextBoxHeight
    t1.Value = question("questionText").ToString()
    t1.Top = New Drawing.Unit(0, UnitType.Cm)
    't1.Top = New Drawing.Unit(StartTop, UnitType.Cm)
    t1.Left = New Drawing.Unit(LeftMargin, UnitType.Cm)
    t1.StyleName = "styleQuestion"
    'pnl.Items.AddRange(New Telerik.Reporting.ReportItemBase() {t1})
    t1.Parent = pnl
    ' When using the below and comment out the parent line above it works fine
    'ReDim Preserve Controls(Controls.Length)
    'Controls(Controls.Length - 1) = t1
    ResultHeight += 0.6
        ' CHECK BOX LIST FOR MULTIPLE OPTIONS
        cbl1.StartTop = 0.6 'StartTop + 0.6
        cbl1.StartTop = StartTop + 0.6
        cbl1.LeftMargin = LeftMargin
        If CInt(question("option1")) = 0 Then
            cbl1.RepeatColumns = 3
        Else
            cbl1.RepeatColumns = CInt(question("option1"))
        End If
        cbl1.DataTextField = "displayText"
        cbl1.DataValueField = "questionDetailId"
        cbl1.DataSource = questionDetail
        cbl1.Width = TextBoxWidth.Value
        Dim trb() As Telerik.Reporting.ReportItemBase
        trb = cbl1.Render()
        ResultHeight += cbl1.ResultHeight
        Dim x As Integer
        For x = 0 To trb.Length - 1
            'pnl.Items.AddRange(New Telerik.Reporting.ReportItemBase() {trb(x)})
            trb(x).Parent = pnl
            ' When using the below and comment out the parent line above it works fine
            'ReDim Preserve Controls(Controls.Length)
            'Controls(Controls.Length - 1) = trb(x)
        Next
    pnl.Height = New Drawing.Unit(ResultHeight, UnitType.Cm)
    ReDim Preserve Controls(Controls.Length)
    Controls(Controls.Length - 1) = pnl
    Return Controls
End Function


It's used like this in the VB code else where:

detail.Items.AddRange(c.RenderControlSet())



Where detail is the details section of the report.

I am using verison 4.0.10.423 of the Telerik.Report.dll

Thanks,

Joel

1 Answer, 1 is accepted

Sort by
0
Ticket Solutions Account
Top achievements
Rank 1
answered on 14 Aug 2010, 07:10 AM
An Update on this, in case anyone else has the same issue.

I submited a request to Telerik Support who replied an suggested that I use the Location and Size properties for the panel.

I was using Left, Top and Hieght, Width, this is what was causing the "strange" results.

Initially in the Code above I'm missing the left property but have the top property for the panel, this was causing the page break after each panel.

This code was created in a very old version of telerik reports (2008 i believe) and ran fine, Telerik have implied that this is not a bug because I wasn't using size and location which are apparently mandatory fields.

Regards,
Joel

Tags
General Discussions
Asked by
Ticket Solutions Account
Top achievements
Rank 1
Answers by
Ticket Solutions Account
Top achievements
Rank 1
Share this question
or