/// <summary>
/// 设置报表
/// </summary>
private void SetReport()
{
if (reportModel != null)
{
if (ReportSource.Count > 0) ReportSource.Clear();
if (this.reportViewer1.LocalReport.DataSources.Count > 0) this.reportViewer1.LocalReport.DataSources.Clear();
ReportSource.Add(reportModel);
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SMAccidentInfo_SimpleReport", ReportSource));
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();
} } private void tsbPrint_Click(object sender, EventArgs e)
{
try
{
SetReport();
this.reportViewer1.PrintDialog();
}
catch (Exception ex)
{
Sys_Error.WriteError(this, ex);
}
}捕捉到 System.InvalidOperationException
Message="对象的当前状态使该操作无效。"
Source="Microsoft.ReportViewer.WinForms"
StackTrace:
在 Microsoft.Reporting.WinForms.ReportViewer.PrintDialog()
在 Report.FrmSimpleReport.tsbPrint_Click(Object sender, EventArgs e) 位置
解决方案 »
- socket只能接受第一条数据
- Word里如何能把代码块以这种形式呈现,而不是满屏的红波浪线拼写错误
- C#winform中更改datagridview的textboxcolumn值用那个事件比较好
- 救命啊!!现场求助!!!!大神快来!!!
- 98下,如何判断网络通断?在线等
- C#引用VB编写的COM (.DLL)文件,提示需要Cannot convert source type 'string' to target type 'System.IntPtr'
- 循环语句,i++ ,怎么取到这个i循环了几次?
- 请教高人,如何使属性具有不同的访问控制?
- 关于rtf格式的问题,请教各位高手
- C#开发上位机,通过RSlinx向AB_PLC中写值
- C# ActiveX插件问题(开启IE后IE自动关闭) 顶者有分
- 关于DataGridView列选中事件
你用得是c/s还是b/s
调用RefreshReport的时候,报表会加载数据并绘制(没有深入了解,怀疑这个地方不是在主进程里面进行的,所以就直接执行PrintDialog(),而不是等待数据加载完成后再执行PrintDialog(),从而导致错误)
timer1.start()在timer1的Tick事件
me.ReportViewer1.PrintDialog()以上可以解决提示出错的问题.
感觉出错的原因是数据未加载完所致的.望有高手能切底解决这一个问题.