gpt4 book ai didi

c# - 单击按钮在新窗口中显示报告

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:15 24 4
gpt4 key购买 nike

我的报告以选中单选按钮的形式显示日期。当我的 radioButton 被选中时,日期显示在报告的下方。当我单击显示按钮(“打印”)时,这些日期需要显示在新窗口中。

private void radioButton1_Checked(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
CrystalReport1 cr1 = new CrystalReport1();
crystalReportViewer1.ReportSource = cr1;
}
}

我的问题是:

private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
MessageBox.Show("Print dates", "Top partners");
}
}

我试图在 MessageBox.Show 中添加我的报告,但收到错误

Can not convert to string.

如何在新窗口中轻松生成报告?或者甚至将其导出为 PDF 或其他格式?

enter image description here

最佳答案

从已执行的 Crystal Report 中提取信息到程序中并不容易。这并非不可能(我想您可以编写一个函数来控制您的鼠标并复制粘贴信息),但绝对不推荐这样做。

相反,您需要使用 C# 编写代码来完成报告的基本功能 - 获取相同的数据集,对数据执行任何计算或过滤,然后返回可用变量中的值。幸运的是,这一切都可以在没有报告的情况下轻松实现,您可以直接复制报告使用的相同 SQL 查询并调整它以在 C# 中运行。将您需要的值作为列表返回,然后 boom - 准备好获取的可用值。

但遗憾的是,没有简单的方法可以从报告中获取值。就技术而言,Crystal 真的很古老,很多现代的敏感性都不适用。

关于c# - 单击按钮在新窗口中显示报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45029854/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com