Problems with report from code
Hello all!
At our company we have just started using fastreports component for .net and we encounter the folowing problem:
If i try to build a report from code ( without a datasource , because i don't need one in this very instance ) and actually place fastreport objects on a band , the object just don't appear.
Also the ones that do appear don't respect the ".left",".top" proprieties which i am setting in code.......
The main point is to draw some objects ( usually TextObject in such a way that is resembles a WBS structure from Project Management theory ) on a databand like on a canvas. The following code is not doing what is it supposed to do when u "read" the code...
The "txtTitlu" object does appear on the report preview but the second object does not.
Also if i open the designer after running the code , the second object is not there and i don't see the title band, groupheader band, databand and the footer band I only see a a big "Overlay" grey band even if a inserted 3 bands in the code above ( following the tutorial for report from code).
If the code/ ideea for creating what i want is wrong , that's ok but i need an alternative from you guys. Keep in mind that i need to be able to move/align the TextObject on the databand at the runtime and place variable number of them on the band depending on the information i have
Thanks!
At our company we have just started using fastreports component for .net and we encounter the folowing problem:
If i try to build a report from code ( without a datasource , because i don't need one in this very instance ) and actually place fastreport objects on a band , the object just don't appear.
Also the ones that do appear don't respect the ".left",".top" proprieties which i am setting in code.......
The main point is to draw some objects ( usually TextObject in such a way that is resembles a WBS structure from Project Management theory ) on a databand like on a canvas. The following code is not doing what is it supposed to do when u "read" the code...
raportWBS = New FastReport.Report
        Dim cm As Single = FastReport.Utils.Units.Centimeters
        Dim page As New FastReport.ReportPage : page.Name = "Pagina"
        raportWBS.Pages.Add(page)
        page.ReportTitle = New FastReport.ReportTitleBand : page.ReportTitle.Name = "TitluRaport" : page.ReportTitle.Height = 1.5F * cm : page.Landscape = True
        Dim groupHeaderBand As New FastReport.GroupHeaderBand : groupHeaderBand.Name = "GrupHeader" : groupHeaderBand.Height = 1.0F * cm
        page.Bands.Add(groupHeaderBand)
        groupHeaderBand.GroupFooter = New FastReport.GroupFooterBand : groupHeaderBand.GroupFooter.Name = "GrupFooter" : groupHeaderBand.GroupFooter.Height = 1.0F * cm
        Dim bandaPrincipala As New FastReport.DataBand : bandaPrincipala.Name = "BandaPrincipala" : bandaPrincipala.Height = 10.0F * cm
        groupHeaderBand.Data = bandaPrincipala
        Dim txtTitlu As New FastReport.TextObject : txtTitlu.Name = "txtTitlu" : txtTitlu.Text = "Ceva"
        txtTitlu.Font = New Font("Tahoma", 14, FontStyle.Bold)
        txtTitlu.HorzAlign = FastReport.HorzAlign.Center : txtTitlu.VertAlign = FastReport.VertAlign.Center
        txtTitlu.Height = 1 * cm : txtTitlu.Width = 3 * cm
        page.ReportTitle.Objects.Add(txtTitlu)
        Dim txtInv As New FastReport.TextObject : txtInv.Name = "txtInv" : txtInv.Text = _dtTask.Select("Tip = 'Inv'")(0)("Denumire").ToString
        txtInv.Font = New Font("Tahoma", 12, FontStyle.Bold)
        txtInv.HorzAlign = FastReport.HorzAlign.Center : txtInv.VertAlign = FastReport.VertAlign.Center
        txtInv.Border.Lines = FastReport.BorderLines.All
        txtInv.Height = 1 * cm : txtInv.Width = 4 * cm
        groupHeaderBand.Data.Objects.Add(txtInv)
        raportWBS.Show()
The "txtTitlu" object does appear on the report preview but the second object does not.
Also if i open the designer after running the code , the second object is not there and i don't see the title band, groupheader band, databand and the footer band I only see a a big "Overlay" grey band even if a inserted 3 bands in the code above ( following the tutorial for report from code).
If the code/ ideea for creating what i want is wrong , that's ok but i need an alternative from you guys. Keep in mind that i need to be able to move/align the TextObject on the databand at the runtime and place variable number of them on the band depending on the information i have
Thanks!
Comments
In the mean time i found a solution and for anyone ho is gone be in the same situation here it is:
1. First use a blank report with ReportTitle band, PageHeader band, Data Band and Page footer band ( fastreport tehnical support suggested that [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> ) 2. The settings from "1" will allow us to draw on the band but still the page height/width refuses to set corectly so use "unlimitedHeight" and "unlimitedWidth" on the Page properties 3. I used the "Data_BeforePrint" event of the databand event to draw/place/construct everything i needed . Here is the code example :[/img]
Have a nice day!