Page 1 of 1

Long to int

Posted: Thu May 30, 2019 2:35 pm
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 !!

Re: Long to int

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

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

Thank you.

Re: Long to int

Posted: Mon Jun 03, 2019 6:18 pm
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 ??

Re: Long to int

Posted: Tue Jun 04, 2019 9:16 pm
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.

Re: Long to int

Posted: Wed Jun 05, 2019 7:53 am
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!).

Re: Long to int

Posted: Wed Jun 05, 2019 12:13 pm
by Lech Kulikowski
Hello,

Thank you for the additional solution.

Re: Long to int

Posted: Wed Jun 05, 2019 12:47 pm
by rafael.custodio
MatthiasU and Lech Kulikowski, thanks for the solutions !! Got it to work.

Re: Long to int

Posted: Thu Jun 06, 2019 5:33 pm
by Lech Kulikowski
Hello

We are always glad to help you!

Thank you.