How to apply a conditional margin to a textbox?

Stimulsoft Reports.NET discussion
rezanew
Posts: 8
Joined: Wed May 09, 2007 11:54 am

How to apply a conditional margin to a textbox?

Post by rezanew »

Hello,

I want to have a conditional margin for a textbox in such a way that check for an "IF" condition and apply different margins related to the condition result.
Is it possible and how?

Thanks
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

How to apply a conditional margin to a textbox?

Post by Jan »

Hello,

You can use following script in BeforePrintEvent of text component:

Code: Select all

if (condition)Text1.Margins = new Stimulsoft.Report.Components.StiMargins(1, 2, 3, 4);
else if (condition)Text1.Margins = new Stimulsoft.Report.Components.StiMargins(0, 0, 0, 0);
Thank you.
rezanew
Posts: 8
Joined: Wed May 09, 2007 11:54 am

How to apply a conditional margin to a textbox?

Post by rezanew »

Thanks for you fast reply,

My condition is different in each row so the textbox margins may have different values in each row. but in your suggested solution, the final condition in the last row is checked and the related margin is applied to all of the rows.. in other words only the last row's condition defines the margin for all of the rows...
rezanew
Posts: 8
Joined: Wed May 09, 2007 11:54 am

How to apply a conditional margin to a textbox?

Post by rezanew »

There is no solution?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to apply a conditional margin to a textbox?

Post by Alex K. »

Hello,
rezanew wrote:My condition is different in each row so the textbox margins may have different values in each row. but in your suggested solution, the final condition in the last row is checked and the related margin is applied to all of the rows.. in other words only the last row's condition defines the margin for all of the rows...
Please send us your .mrt file with database for analysis on support@stimulsoft.com.
Could you explain your issue in more details?

Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: How to apply a conditional margin to a textbox?

Post by tpontow »

Any solution for that Topic? Stimulsoft is still behaving in the same way today!

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)
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: How to apply a conditional margin to a textbox?

Post by Lech Kulikowski »

Hello,

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

Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: How to apply a conditional margin to a textbox?

Post by tpontow »

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)
Lech Kulikowski
Posts: 6266
Joined: Tue Mar 20, 2018 5:34 am

Re: How to apply a conditional margin to a textbox?

Post 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.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: How to apply a conditional margin to a textbox?

Post by tpontow »

Hi Lech,

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)
Post Reply