Change Styles at runtime

Stimulsoft Reports.NET discussion
Post Reply
khalid89
Posts: 6
Joined: Wed May 04, 2011 10:34 am
Location: Capital Federal

Change Styles at runtime

Post by khalid89 »

Hi! I need to set the ComponentStyle, EvenStyle and OddStyle properties at runtime. I'm working on an ASP.NET project and I need to do it on my C# code.
I have tried with:
dataBand1.EvenStyle = "Data3";
dataBand1.OddStyle = "Data2";
(report.Pages["Page1"].GetComponents()["DataBand1"] as StiDataBand).EvenStyle = "";
(report.Pages["Page1"].GetComponents()["DataBand1"] as StiDataBand).OddStyle = "Odd";
StiText1.ComponentStyle = "Data3";

But I have no results.
I hope you can help me,
Best regards,
Seb . .
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Change Styles at runtime

Post by Alex K. »

Hello,

First, you must add the desired style

Code: Select all

Stimulsoft.Report.StiStyle StyleData1 = new Stimulsoft.Report.StiStyle();
StyleData1.AllowUseBorderFormatting = false;
StyleData1.AllowUseBorderSides = false;
StyleData1.AllowUseFont = false;
StyleData1.AllowUseTextBrush = false;
StyleData1.AllowUseTextOptions = false;
StyleData1.Name = "Odd";
StyleData1.StyleCode = Stimulsoft.Report.StiStyleCode.None;
StyleData1.Border = new Stimulsoft.Base.Drawing.StiBorder(Stimulsoft.Base.Drawing.StiBorderSides.None, System.Drawing.Color.Black, 1, Stimulsoft.Base.Drawing.StiPenStyle.Solid, false, 4, new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Black), false);
StyleData1.Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.FromArgb(255, 240, 237, 232));
StyleData1.Font = new System.Drawing.Font("Arial", 9F);
StyleData1.Image = null;
StyleData1.TextBrush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Black);

report.Styles.Clear();
report.Styles.AddRange(new Stimulsoft.Report.StiBaseStyle[] {
            StyleData1});
and then only to assign it:

Code: Select all

dataBand2.EvenStyle = "Odd";
Thank you.
khalid89
Posts: 6
Joined: Wed May 04, 2011 10:34 am
Location: Capital Federal

Change Styles at runtime

Post by khalid89 »

Aleksey, thanks a lot for your answer =)
If I want to add more than one Style, I have not use report.Styles.Clear(), am I right?

Best regards,
Seb . .
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Change Styles at runtime

Post by Alex K. »

Hello,

You can define several styles and then add them to the collection of styles.

Thank you.
Post Reply