Page 1 of 1

Set ComponentStyle at Runtime

Posted: Mon Jul 20, 2015 12:02 pm
by vorauler
Hello

I have defined some styles in a report, now I will set these styles depending of a properties from my buisness object to a shape.
Is this possible? At the moment I use this code, but i would like to use style objects:

Code: Select all

		private void SetShapeColor()
		{
			this.shapeQuestion1.Brush = this.GetBrushOnStatus(Insurant.Phase1Question1);
		}

		private StiSolidBrush GetBrushOnStatus(int state)
		{
			if (state == 0)
				return new StiSolidBrush(Color.Red);
			else if (state == 1)
				return new StiSolidBrush(Color.Blue);
			else if (state == 2)
				return new StiSolidBrush(Color.Green);

			return new StiSolidBrush(Color.White);
		}
TIA
Ralf

Re: Set ComponentStyle at Runtime

Posted: Tue Jul 21, 2015 10:55 am
by HighAley
Hello, Ralf.

In this case it's better to add Conditions in code. Here is a sample code snippet.

Code: Select all

            var comp = report.GetComponentByName("Text1");
            var condition = new StiCondition();
            condition.Style = "yourStyle";
            condition.Item = StiFilterItem.Expression;
            condition.Expression = new StiExpression("yourexpression");
            comp.Conditions.Add(condition);
Thank you.