首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >C# -将数据表绑定到报表查看器

C# -将数据表绑定到报表查看器
EN

Stack Overflow用户
提问于 2013-06-29 03:40:06
回答 1查看 2.2K关注 0票数 2

我试图在运行时将DataTable绑定到winforms中的reportviewer,但在reportviewer中收到此消息(而不是异常)。“

尚未指定报表定义的来源“

下面是我的代码:

代码语言:javascript
复制
this.rptViewer.LocalReport.DataSources.Clear(); 

ReportDataSource rprtDTSource = new ReportDataSource(dt.TableName, dt); 

this.rptViewer.LocalReport.DataSources.Add(rprtDTSource); 
this.rptViewer.RefreshReport(); 

有什么想法吗?

EN

Stack Overflow用户

回答已采纳

发布于 2013-06-29 03:41:40

试着这样做:

代码语言:javascript
复制
var reportDataSource1 = new ReportDataSource { Name = "WpfApplication17_User", Value = _users };
string exeFolder = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
_reportViewer.LocalReport.ReportPath =exeFolder + @"\Reports\Report1.rdlc";
_reportViewer.LocalReport.DataSources.Add(reportDataSource1);
_reportViewer.RefreshReport();

here (Codeproject)那里得到了答案。

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17372407

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档