Long to int

Stimulsoft Reports.NET discussion
Post Reply
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Long to int

Post by rafael.custodio »

Hi !! I´m trying to have a DataBand in a report that will set the number of columns depending on the number of rows.
I´m trying this on the before print event and getting an error about implicit conversion:

DataBand1.Columns = Count(DataBand1)

Then I tried this but it didn't work:

DataBand1.Columns = int.Parse(Count(DataBand1))

I also tried to create a variable as int and it didn't work as well:

ColSize = Count(DataBand1));
DataBand1.Columns = ColSize


How can I solve this problem ??

And would it be possible to set the width of the column the same as the width of a text component on something like this :

DataBand1.ColumnWidth = Text1.Width

Thanks in advanced !!
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski »

Hello,

Please try to use the following code in the BeforePrint event of the Page:
DataBand1.Columns = DataSource.Count;

Thank you.
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Re: Long to int

Post by rafael.custodio »

Lech Kulikowski wrote: Sun Jun 02, 2019 7:53 pm Hello,

Please try to use the following code in the BeforePrint event of the Page:
DataBand1.Columns = DataSource.Count;

Thank you.
Lech Kulikowski, thank you so much !! It worked like a charm !!
Now I have the second part of my question:

DataBand1.ColumnWidth = Text1.Width

The problem is: the object Text1 is set as AutoWidth and when I try to get the width of the object I only get what's set in the report, I would like to get the value that it is given when I run the report so I can set the column width to that value.
Would it be possible ??
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski »

Hello,

You can try to use DoublePass, in the first check and save widths and in the second set it.

Thank you.
MatthiasU
Posts: 68
Joined: Mon Sep 14, 2015 8:33 am

Re: Long to int

Post by MatthiasU »

Or just call method GetActualSize() of the text element (returns SizeD). Ensure that correct text has been set before (this method does not trigger any event of the text box!).
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski »

Hello,

Thank you for the additional solution.
rafael.custodio
Posts: 31
Joined: Thu May 30, 2019 1:01 pm

Re: Long to int

Post by rafael.custodio »

MatthiasU and Lech Kulikowski, thanks for the solutions !! Got it to work.
Lech Kulikowski
Posts: 6243
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski »

Hello

We are always glad to help you!

Thank you.
Post Reply