This is a migrated thread and some comments may be shown as answers.

Telerik.Reporting.Drawing.Style

3 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jasper
Top achievements
Rank 1
Jasper asked on 09 Sep 2010, 01:29 PM
Hi,

I'm trying to find out how to style a report programatically. Thought it would be a good idea to create an object of type Style, setting all the values, passing the style object to the report and simply set <reportItem>.Style = <myStyleObject>. Unfortunately the constructor of Telerik.Reporting.Drawing.Style is not exposed. and the style-property has no setter.

Are there any workarounds for setting the style property programatically (I know that I can set individual properties, but that is not want I am looking for)?

Kind Regards

3 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 09 Sep 2010, 02:48 PM
Create the style through the report designer and then review the generated code in InitializeComponent. At least this is what I do as I find it much easier than drilling down the API reference. The documentation also contains articles about the built-in styling of TL, so you might give it a go: http://www.telerik.com/help/reporting/style-overview.html
0
Jasper
Top achievements
Rank 1
answered on 09 Sep 2010, 03:23 PM
Hi Massimiliano, thanks for your reply.

The designer just sets every style property individual (eg. Style.Font.Bold =...), no problem to do this by myself, but its not good style to set any property one by one. I've already checked the documentation and the link you posted but it does not help me setting the report item style in a nifty way.


Kind Regards
0
Accepted
Peter
Telerik team
answered on 10 Sep 2010, 02:46 PM
Hello Jasper,

Style definitions can be stored in a Style Rule. Style Rules can be created in the designer or in code as shown in the following code snippet.

Telerik.Reporting.Drawing.StyleRule styleRule1 = new Telerik.Reporting.Drawing.StyleRule();
styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
new Telerik.Reporting.Drawing.StyleSelector("MyStyle")});
styleRule1.Style.BackgroundColor = System.Drawing.Color.Red;
styleRule1.Style.BorderStyle.Default = Telerik.Reporting.Drawing.BorderType.Solid;
this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] {
styleRule1});
this.textBox1.StyleName = "MyStyle";
this.textBox2.StyleName = "MyStyle";

For more information on the topic check out the Creating Style Rules help article.

Best wishes,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Jasper
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Jasper
Top achievements
Rank 1
Peter
Telerik team
Share this question
or