Page 1 of 1

Adding Bound Data Column to report at run time

Posted: Fri May 04, 2007 9:16 am
by spv123
I'm trying to use stimulreport.net to generate dynamic reports (ie dyamically create columns based on the dataset).

I've found how to connect a dataset to a form, but now I'm trying to create a text box to pick up a field from my dataset. I know I'm doing it wrong, but I'm not sure what to do to make it correct...

Here is my code :

Code: Select all

        ' Build Dataset
        Dim ds As DataSet
        dms.CreateRecordOnly("Result")
        dms.CreateRecordOnly("tmp")
        dms.dataDate("tmp", 1) = "01/01/05"
        dms.dataDate("tmp", 2) = "01/05/07"
        dms.data("tmp", 3) = "1"
        dms.record("Result") = dms.CallProg("WIN.VEHICLES.DELIVERY.REPORT", DMS.record("tmp"))
        ds = dms.BuildDataSet("Result")
        ds.Tables(0).TableName = "spv"

       ' Register dataset onto report
        Me.StiReport1.RegData("spv", ds.Tables(0))
        Me.StiReport1.DataStore.RegData("spv", ds.Tables(0))
        StiReport1.Dictionary.Synchronize()

        ' Now Dynamically Add Data column - For data column "Model" in dataset
        Dim tb As New Stimulsoft.Report.ReportControls.StiTextBoxControl
        tb.Left = 6.0
        tb.Top = 0
        tb.Text = "{Spv.Model}"
        Dim stico As Stimulsoft.Report.Components.StiDataBand
        Dim stipage As Stimulsoft.Report.Components.StiPage
        stico = CType(Me.StiReport1.GetComponentByName("DataBand1"), Stimulsoft.Report.Components.StiDataBand)
        stipage = CType(Me.StiReport1.GetComponentByName("Page1"), Stimulsoft.Report.Components.StiPage)
        tb.Parent = stico
        tb.Page = stipage


        StiReport1.Compile()
        StiReport1.Render(False)
        StiReport1.Show()
What should I be doing instead?

Regards
Simon

Adding Bound Data Column to report at run time

Posted: Fri May 04, 2007 10:56 am
by Brendan
the StiTextBoxControl you are using it for the Form Designer in the Report.
You need to reference the components inside Stimulsoft.Report.Components.

StiText represents a textbox on a report page

There's an Example on how to create Runtime reports in the installed samples. It's called RuntimeBuildReport.

To add a Textbox to a Databand at runtime the following can be done:

Code: Select all


        Dim Page As StiPage = Me.StiReport1.Pages.Item(0)

        'Create Databand
        Dim Databand As New StiDataBand()
        Databand.DataSourceName = "spv"
        Databand.Height = 0.5
        Databand.Name = "DataBand1"
        Page.Components.Add(Databand)

        'Create text
        Dim DataText As New StiText(New RectangleD(0, 0, 5, 0.5))
        DataText.Text.Value = "{Spv.Model}"
        DataText.Name = "DataText1"
        Databand.Components.Add(DataText)

Adding Bound Data Column to report at run time

Posted: Fri May 04, 2007 1:23 pm
by Vital
Please see sample project PrintGrid in standard delivery pack.

Thank you.