Dynamic Columns

Stimulsoft Reports.NET discussion
paullef
Posts: 41
Joined: Thu Jan 17, 2013 5:06 pm

Dynamic Columns

Post by paullef »

Hello,

I am trying to adapt the printtable example, to integrate this in the events of a report. I want to have multiple objects on a page, including a databand which shows all columns of a (dynamic) datatable. I am trying to set this code in the databand/page/report beginrenderevent, and it creates the textboxes but no data is shown. Do I need another event, or what am I doing wrong?

Secondly, can the pagewidth be dynamicly be adjusted to the widht of this databand (with multiple columns)?

Thanks
Paul

dim i as integer

for i = 0 to DataTable.Columns.Count - 1
Dim DataText As New StiText(New RectangleD(i, 0, 10, 0.5))
DataText.Text.Value = "{DataTable." & DataTable.Columns(i).Name & "}"
DataText.Name = "DataText" & i
DataText.Border.Side = StiBorderSides.All

Databand1.Components.Add(DataText)
next
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamic Columns

Post by HighAley »

Hello.

Sorry, maybe we don't understand your task.
Could you describe your task with multiple objects more detailed with samples?

As about page width, you could set the Segment per Width property of the page. The segment with page width will be added.

Thank you.
paullef
Posts: 41
Joined: Thu Jan 17, 2013 5:06 pm

Re: Dynamic Columns

Post by paullef »

On a part of the report (on a page) I want to report the content of a table, including all fields. This table is dynamic and therefore I must have multiple columns. On the first page of this report, certain statistics must be shown, this is not a dynamic page.

I am trying to adept the columns of the databand in which I want to display these records and fields, by using the beginrenderevent.

Thanks
Paul
paullef
Posts: 41
Joined: Thu Jan 17, 2013 5:06 pm

Re: Dynamic Columns

Post by paullef »

I have managed to get this working, by adding a addhandler, and using reflection to get dynamicly to the properties of the datatable (and to the fieldinformation).

Thanks
Paul
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamic Columns

Post by HighAley »

Hello.

Did you try to create the report dynamically in code? Here is a sample.
DynamicCreateReport.zip
(15.46 KiB) Downloaded 645 times
Also you could look at the Selecting Columns demo report in Dialogs section of our Demo.

Thank you.
paullef
Posts: 41
Joined: Thu Jan 17, 2013 5:06 pm

Re: Dynamic Columns

Post by paullef »

No, I used the beginrenderevent event to add code, for the creation of the fields, and adding a addhandler. The addhandler calls a function which I added in the code part of the report, getting the content of the fields. This is done using reflection, to get the content of the properties of a datasource.

All working.

Thanks
Paul
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamic Columns

Post by HighAley »

Hello, Paul.

Good. Let us know if you need additional help.

Thank you.
User avatar
jp2code
Posts: 20
Joined: Thu Feb 11, 2016 9:10 pm
Location: Longview, TX [USA]

Re: Dynamic Columns

Post by jp2code »

I believe I am trying to do the same thing.

I have a user supplied boolean parameter p_boolPrintProfit.

If it is TRUE, the PROFIT column should display.

If it is FALSE, the "PROFIT" column should not display.

Image
HighAley wrote:Hello.

Did you try to create the report dynamically in code? Here is a sample.
DynamicCreateReport.zip
Also you could look at the Selecting Columns demo report in Dialogs section of our Demo.

Thank you.
I've downloaded this example to take a look at it.

It it solves my issue, I will post back.
~Joe
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamic Columns

Post by HighAley »

Hello.

The sample shows how to create a report template in code dynamically.
If you need to hide the component in the report, you could use the Conditions and disable there Component is Enabled option.

Thank you.
User avatar
jp2code
Posts: 20
Joined: Thu Feb 11, 2016 9:10 pm
Location: Longview, TX [USA]

Re: Dynamic Columns

Post by jp2code »

Thanks!

I followed this up with my own question, to stop hi-jacking this thread.

How to set Report Variable from Visual Studio code?
~Joe
Post Reply