Long to int

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

Long to int

Post by rafael.custodio » Thu May 30, 2019 2:35 pm

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: 1871
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski » 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.
rafael.custodio
Posts: 15
Joined: Thu May 30, 2019 1:01 pm

Re: Long to int

Post by rafael.custodio » Mon Jun 03, 2019 6:18 pm

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: 1871
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski » Tue Jun 04, 2019 9:16 pm

Hello,

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

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

Re: Long to int

Post by MatthiasU » Wed Jun 05, 2019 7:53 am

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: 1871
Joined: Tue Mar 20, 2018 5:34 am

Re: Long to int

Post by Lech Kulikowski » Wed Jun 05, 2019 12:13 pm

Hello,

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

Re: Long to int

Post by rafael.custodio » Wed Jun 05, 2019 12:47 pm

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

Re: Long to int

Post by Lech Kulikowski » Thu Jun 06, 2019 5:33 pm

Hello

We are always glad to help you!

Thank you.
Post Reply