Change cell's margin with conditions
-
- Posts: 25
- Joined: Tue Apr 11, 2017 4:47 pm
Change cell's margin with conditions
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?
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
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.
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.
-
- Posts: 25
- Joined: Tue Apr 11, 2017 4:47 pm
Re: Change cell's margin with conditions
Hello!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.
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
Hello,
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:
Thank you.
It's a memory optimization: when a clone of the base component is created, properties that rarely change, are not cloned but copied.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.
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);
}
Re: Change cell's margin with conditions
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.
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
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);
Thanks
Thorsten Pontow
Thorsten Pontow
It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: Change cell's margin with conditions
Hello,
Please send us a sample report with test data which reproduces the issue for analysis.
Thank you.
Please send us a sample report with test data which reproduces the issue for analysis.
Thank you.
Re: Change cell's margin with conditions
Take any sample Report and set that above code to BeforePrint-Event of any text component you like.
Thorsten Pontow
It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: Change cell's margin with conditions
Hello,
Please check the following code:
Thank you.
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);
Re: Change cell's margin with conditions
Hi Lech,
that solution works. Great! Thanks for your kind help and support.
Best regards
Thorsten Pontow
that solution works. Great! Thanks for your kind help and support.
Best regards
Thorsten Pontow
Thorsten Pontow
It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
-
- Posts: 6198
- Joined: Tue Mar 20, 2018 5:34 am
Re: Change cell's margin with conditions
Hello
We are always glad to help you!
Do not hesitate to contact us in case of further questions.
Thank you.
We are always glad to help you!
Do not hesitate to contact us in case of further questions.
Thank you.