CrystalReportViewer打印

发布于 2024-11-02 02:23:32 字数 90 浏览 1 评论 0原文

我想在 ASP.NET C# 中访问 CrystalReportViewer 的打印事件(当我单击 CrystalReportViewer 的“打印”按钮时),如何?

I would like to access the Print event of CrystalReportViewer(while I click the Print button of CrystalReportViewer) in ASP.NET C#, How ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深者入戏 2024-11-09 02:23:32

像下面这样的东西应该可以工作。希望有帮助。

    public Form1()
    {
        InitializeComponent();
        foreach (ToolStrip ts in crystalReportViewer1.Controls.OfType<ToolStrip>())
        {
            foreach (ToolStripButton tsb in ts.Items.OfType<ToolStripButton>())
            {
                //hacky but should work. you can probably figure out a better method
                if (tsb.ToolTipText.ToLower().Contains("print"))
                {
                    //Adding a handler for our propose
                    tsb.Click += new EventHandler(printButton_Click);
                }
            }
        } 
    }

    private void printButton_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Printed");
    }

Something like the below should work. Hope it helps.

    public Form1()
    {
        InitializeComponent();
        foreach (ToolStrip ts in crystalReportViewer1.Controls.OfType<ToolStrip>())
        {
            foreach (ToolStripButton tsb in ts.Items.OfType<ToolStripButton>())
            {
                //hacky but should work. you can probably figure out a better method
                if (tsb.ToolTipText.ToLower().Contains("print"))
                {
                    //Adding a handler for our propose
                    tsb.Click += new EventHandler(printButton_Click);
                }
            }
        } 
    }

    private void printButton_Click(object sender, EventArgs e)
    {
        MessageBox.Show("Printed");
    }
优雅的叶子 2024-11-09 02:23:32

这并不是一个真正的新答案,但这是使用 .NET 框架对象等的 C++ 中的上述内容:

    CRXViewerNetControl(void)
    {
        InitializeComponent();

        // OK, go though the CRViewer and find the Print Button in the toolbar.  When we find it,
        // attach a "Click" event handler so that we can detect the operator clicking the button to
        // print the report.
        for (Int32 i = 0; i < CRXViewer->Controls->Count; i++)
        {
            if (dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]))
            {
                System::Windows::Forms::ToolStrip^ ctlToolStrip = dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]);
                for (int j = 0; j < ctlToolStrip->Items->Count; j++)
                {
                    if (dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]))
                    {
                        System::Windows::Forms::ToolStripButton^ ctlToolStripButton = dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]);
                        if (ctlToolStripButton->ToolTipText->ToLower()->Contains("print"))
                        {
                            //Adding a handler for our propose
                            ctlToolStripButton->Click += gcnew System::EventHandler(this, &CRXViewerNetControl::printButton_Click);
                        }
                    }
                }
            }
        }

    }

private: System::Void printButton_Click(System::Object^  sender, System::EventArgs^  e) 
    {   
        MessageBox::Show("Printed");
    }

Not really a new answer but here is the above in C++ using .NET framework objects etc.:

    CRXViewerNetControl(void)
    {
        InitializeComponent();

        // OK, go though the CRViewer and find the Print Button in the toolbar.  When we find it,
        // attach a "Click" event handler so that we can detect the operator clicking the button to
        // print the report.
        for (Int32 i = 0; i < CRXViewer->Controls->Count; i++)
        {
            if (dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]))
            {
                System::Windows::Forms::ToolStrip^ ctlToolStrip = dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]);
                for (int j = 0; j < ctlToolStrip->Items->Count; j++)
                {
                    if (dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]))
                    {
                        System::Windows::Forms::ToolStripButton^ ctlToolStripButton = dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]);
                        if (ctlToolStripButton->ToolTipText->ToLower()->Contains("print"))
                        {
                            //Adding a handler for our propose
                            ctlToolStripButton->Click += gcnew System::EventHandler(this, &CRXViewerNetControl::printButton_Click);
                        }
                    }
                }
            }
        }

    }

private: System::Void printButton_Click(System::Object^  sender, System::EventArgs^  e) 
    {   
        MessageBox::Show("Printed");
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文