Page 1 of 1

Change cell's margin with conditions

Posted: Wed Jul 26, 2017 2:20 pm
by lsilva.gvdasa
Hello,

I'm using the table component and need to apply some manipulation on cell's margin according to a condition.

I'm trying something like:

if (varCont == 4) {
CellName.Margins.Left = 20;
} else {
CellName.Margins.Left = 0;
}

But it seems like the component picks up the last value setted for left on CellName for all occurrences of this cell in the rows appeared in the table.

Thanks.

Is it possible to change the CellName's properties for each row appeared?

Re: Change cell's margin with conditions

Posted: Wed Jul 26, 2017 8:01 pm
by HighAley
Hello.

The Table component is created to simplifuy the creation of reports.
At the rendering time this component is converted to Header, Footer and Data Bands.
Please, try to replace the table component with these components. They are more flexible.

Thank you.

Re: Change cell's margin with conditions

Posted: Thu Jul 27, 2017 2:28 pm
by lsilva.gvdasa
HighAley wrote:Hello.

The Table component is created to simplifuy the creation of reports.
At the rendering time this component is converted to Header, Footer and Data Bands.
Please, try to replace the table component with these components. They are more flexible.

Thank you.
Hello!

I'm changing right now to data bands with text components inside, but it seems like I can't change the text margin with conditions. Is there any limitations about it?

Re: Change cell's margin with conditions

Posted: Fri Jul 28, 2017 2:19 am
by Ivan
Hello,
But it seems like the component picks up the last value setted for left on CellName for all occurrences of this cell in the rows appeared in the table.
It's a memory optimization: when a clone of the base component is created, properties that rarely change, are not cloned but copied.
So all instances of a base component have in Margins the same object (not the clone).
If you want to modify margins, you need to create a new object, for example:

Code: Select all

if (varCont == 4) {
CellName.Margins = new Stimulsoft.Report.Components.StiMargins(20, 0, 0, 0);
} else {
CellName.Margins. = new Stimulsoft.Report.Components.StiMargins(0, 0, 0, 0);
}
Thank you.

Re: Change cell's margin with conditions

Posted: Fri Nov 23, 2018 1:08 pm
by tpontow
Sorry, but it's not working.

I tried to set a different margin (10 instead of 5) for a text component only on second line. But it does not work. All lines are affected.

Code: Select all

if (Line == 2)DataTabelle1_Konto.Margins = new Stimulsoft.Report.Components.StiMargins(20,0,0,0);
else DataTabelle1_Konto.Margins = new Stimulsoft.Report.Components.StiMargins(5,0,0,0);
Take any sample Report and set that above code to BeforePrint-Event of any text component you like. It's not working. You cannot change margin for only one row.

Thanks
Thorsten Pontow

Re: Change cell's margin with conditions

Posted: Fri Nov 23, 2018 10:05 pm
by Lech Kulikowski
Hello,

Please send us a sample report with test data which reproduces the issue for analysis.

Thank you.

Re: Change cell's margin with conditions

Posted: Mon Nov 26, 2018 7:33 am
by tpontow
Take any sample Report and set that above code to BeforePrint-Event of any text component you like.

Re: Change cell's margin with conditions

Posted: Thu Nov 29, 2018 9:17 am
by Lech Kulikowski
Hello,

Please check the following code:

Code: Select all

Text1.Properties = Text1.Properties.Clone() as Stimulsoft.Base.StiRepositoryItems;
if (Line > 3) Text1.Margins = new Stimulsoft.Report.Components.StiMargins(20, 0, 0, 0);
else Text1.Margins = new Stimulsoft.Report.Components.StiMargins(0, 0, 0, 0);
Thank you.

Re: Change cell's margin with conditions

Posted: Thu Nov 29, 2018 9:43 am
by tpontow
Hi Lech,

that solution works. Great! Thanks for your kind help and support.

Best regards
Thorsten Pontow

Re: Change cell's margin with conditions

Posted: Thu Nov 29, 2018 12:15 pm
by Lech Kulikowski
Hello

We are always glad to help you!
Do not hesitate to contact us in case of further questions.

Thank you.