bjqxst 发表于 2016-3-25 13:47:18

activereports标题怎么赋值

本帖最后由 Lenka.Guo 于 2016-3-25 16:41 编辑

activereports标题怎么赋值在DataTable 中,怎么给activereports的标题,x轴标题,y轴标题,赋值。
DataTable dt = new DataTable();
dt.Columns.Add("FieldX");
            dt.Columns.Add("FieldY", typeof(int));
            dt.Rows.Add("勘察设计", 68);
            dt.Rows.Add("监理", 62);
            dt.Rows.Add("施工", 201);
            dt.Rows.Add("采购", 20);
            return dt;


Lenka.Guo 发表于 2016-3-25 16:41:08

您指的是为Chart控件的标题, X轴标题和Y轴标题 通过后台数据赋字段值?

您可以选中标题,在属性窗口中,选择Title属性,选中表达式,选中想要设置的字段,
或者您可以使用同样的方法通过报表参数,为轴标题或图表标题赋值。




http://gcdn.gcpowertools.com.cn/forum.php?mod=image&aid=21102&size=300x300&key=7c9a095fd118b1d7&nocache=yes&type=fixnone

bjqxst 发表于 2016-3-28 16:36:41

Lenka.Guo 发表于 2016-3-25 16:41
您指的是为Chart控件的标题, X轴标题和Y轴标题 通过后台数据赋字段值?

您可以选中标题,在属性窗口中, ...

后台怎么给字段赋值,例如加了FieldTitle,FieldXTitle,FieldYTitle,3个字段。后台怎么赋值,代码贴出了。

Lenka.Guo 发表于 2016-3-28 17:28:20

报表中使用的字段,都是后台数据源绑定时设置的。
您的代码中:

DataTable dt = new DataTable();
//添加字段名称;
dt.Columns.Add("FieldXTitle");
dt.Columns.Add("FieldYTiltle");
//为字段添加值;   
            dt.Rows.Add("勘察设计", 68);
            dt.Rows.Add("监理", 62);
            dt.Rows.Add("施工", 201);
            dt.Rows.Add("采购", 20);
            return dt;


您是想通过后台传进的参数,来为图表标题赋值还是想通过后台的数据集中的字段为图表赋值?

bjqxst 发表于 2016-3-28 17:40:29

Lenka.Guo 发表于 2016-3-28 17:28
报表中使用的字段,都是后台数据源绑定时设置的。
您的代码中:



你没懂我的意思。
我的意思是,怎么修改标题,一个图就1个标题。你贴的代码,不是修改标题啊。
例如后台赋值X轴的标题为,2015年的情况,2014年的情况,

bjqxst 发表于 2016-3-28 17:50:41

Lenka.Guo 发表于 2016-3-28 17:28
报表中使用的字段,都是后台数据源绑定时设置的。
您的代码中:



怎么给标题赋值?

Lenka.Guo 发表于 2016-3-28 18:20:37

您好,通过验证使用变量只能为图表Title赋值,无法为X轴和Y轴赋值,所以建议在报表中设置参数,然后通过参数为标题赋值:

1. 添加报表参数2. 为AxisX的Title赋参数值


3. 在后台在PageLoad事件中为参数赋值:
rpt.Report.ReportParameters.DefaultValue.Values.Add("string123");


图表Title赋值可参考:

GrapeCity.ActiveReports.PageReportModel.Chart crp = rpt.Report.Body.ReportItems as GrapeCity.ActiveReports.PageReportModel.Chart;
            GrapeCity.ActiveReports.PageReportModel.Title Title = new GrapeCity.ActiveReports.PageReportModel.Title();
            Title.Caption = ExpressionInfo("stringValue")// 这句可能有点小问题,见谅~
            crp.Title = Title;




bjqxst 发表于 2016-3-28 19:06:37

Lenka.Guo 发表于 2016-3-28 18:20
您好,通过验证使用变量只能为图表Title赋值,无法为X轴和Y轴赋值,所以建议在报表中设置参数,然后通过参 ...

在这个方法中怎么写。你写的rpt,我的页面中没有。

Lenka.Guo 发表于 2016-3-29 09:34:10

抱歉没说清楚。。
代码是在生成报表对象时添加的, 而不是在加载数据源时添加的。您的OnLocateDataSourceHandler是加载数据源的函数。

在后台在PageLoad事件中为参数赋值:,rpt是生成的报表对象。

string file_name = @"..\..\RdlReport1.rdlx";
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));


rpt.Report.ReportParameters.DefaultValue.Values.Add("string123");

bjqxst 发表于 2016-3-31 14:43:07

我的标题还是没有显示出来。显示的是Parameters!ReportParameter1.Value
strFFN="report.rdlx";
GrapeCity.ActiveReports.PageReport report1 = null;
            report1 = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(strFFN));
            report1.Report.ReportParameters.DefaultValue.DataSetReference.LabelField = "sdf";
            report1.Report.ReportParameters.DefaultValue.DataSetReference.ValueField = "sdf";
            report1.Report.ReportParameters.DefaultValue.Values.Add("string123");
页: [1] 2
查看完整版本: activereports标题怎么赋值