1.相关资源
这里是院子里面一些关于activeReport 2.0的内容,有一定的参考价值。
http://www.cnblogs.com/dahuzizyd/archive/2007/04/11/ActiveReport_All.html
2.个人心得 (chart 控件)
1.修改样式,
- 通过 wizard ,customize,里面的appearance。
- save style.xml
- 再次使用时.load style.xml 。
2.add annotation
1 int No = 1;
2 foreach (DataRow drs in currentDataTable.Rows)
3 {
4 // create the annotation lines and text bars
5 DataDynamics.ActiveReports.Chart.Annotations.AnnotationLine aLine1 = new
6 DataDynamics.ActiveReports.Chart.Annotations.AnnotationLine();
7 DataDynamics.ActiveReports.Chart.Annotations.AnnotationTextBar aText1 = new
8 DataDynamics.ActiveReports.Chart.Annotations.AnnotationTextBar();
9 // set the properties for each line and text bar
10 aLine1.EndPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(0.5F * No, 20F);
11 aLine1.StartPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(0.5F * No, 0F);
12 aLine1.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red,
13 2);
14 aText1.AnchorPlacement = DataDynamics.ActiveReports.Chart.Annotations.AnchorPlacementType
15 .Bottom;
16 aText1.AnchorPoint = new DataDynamics.ActiveReports.Chart.Graphics.Point2d(0.5F * No, 21F);
17 aText1.Height = 25F;
18 aText1.Line = new DataDynamics.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Red,
19 2);
20 aText1.Text = string.Format("{0}", drs["PaiMing"]);
21 aText1.Width = 40F;//控制宽度
22 aText1.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(Color.Black);
23 aText1.Font = new DataDynamics.ActiveReports.Chart
24 .FontInfo(Color.White, new Font("宋体",18f));
25 // add the annotation lines and text bars to the annotations collection for the series
26 this.ChartControl.Series[0].Annotations.AddRange(new DataDynamics.ActiveReports.Chart
27 .Annotations.Annotation[] { aLine1, aText1 });
28 No += 2;
29
这里的annotation的字体颜色都是可以修改的,只要设置一下text的font属性就可以了。
3.change backdrop
1 foreach (DataDynamics.ActiveReports.Chart.DataPoint dp in ChartControl.Series[0].Points)
2 {
3 dp.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(
4 GetColorRule(int.Parse(dp.YValues.ToString()), max, avg));
5
4.add line with AxisY
1 DataDynamics.ActiveReports.Chart.WallRange avgWall = new DataDynamics.ActiveReports
2 .Chart.WallRange();
3 avgWall.StartValue = avg;
4 avgWall.EndValue = avg + 1;
5 avgWall.Backdrop = new DataDynamics.ActiveReports.Chart.Graphics.Backdrop(System.Drawing
6 .Color.White);
7 avgWall.Border = new DataDynamics.ActiveReports.Chart.Border(new DataDynamics
8 .ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Transparent, 0, DataDynamics
9 .ActiveReports.Chart.Graphics.LineStyle.None), 0, System.Drawing.Color.Black);
10 avgWall.PrimaryAxis = (DataDynamics.ActiveReports.Chart.Axis)this.ChartControl
11 .ChartAreas[0].Axes["AxisY"];
12 this.ChartControl.ChartAreas[0].WallRanges.AddRange(new DataDynamics.ActiveReports.Chart
13
猜想应该有很多人都被这个红线弄得很苦恼了吧,呵呵。
之前在网上搜了一下都没有很好的解决办法,我来说一下我的去掉的方法。
这个红线的作用是,提示用户,当前界面的宽度已经超过了纸张的大小,在打印报表的时候会打印成好几张纸,
那么如何调整纸张大小呢,或者如何去掉红线呢,网上有一些方法是把左右的margin去掉,因为左右的margin+
内容的宽度如果小一点就可以,不会显示红线了,不过我觉得这招不好使,因为内容还是有可能会宽,我想到的方法是
在ReportStart 事件中,重新设定纸张的大小,那么就Ok了,代码如下:
1 private void DiaoBoFaHuo_ReportStart(object sender, System.EventArgs eArgs)
2 {
3 #region 改变默认纸张的大小
4 this.PageSettings.PaperHeight = 11.0f;
5 this.PageSettings.PaperWidth = 17.0f;//这个值必须大一点,不过似乎太大会
6 this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Custom;
7
8 #endregion
9
三。官方帮助
其实大多数功能在官方的帮助上都可以找的到,人家的帮助文档写的真是好,既然已经可以免费使用人家的东西了,那么就不要去破解了。。。^_^