【问题标题】:How to show print dialogue when i press control + P in windows form当我在 Windows 窗体中按 control + P 时如何显示打印对话框
【发布时间】:2020-10-15 18:51:30
【问题描述】:

当我在 windows 窗体中按 control + P 时如何显示打印对话框。 我已经有一个report1.rdlc 和reportviewer1。在第二种形式。如何以 Main(First form) 打印此报告?

【问题讨论】:

标签: c#


【解决方案1】:

这可能会有所帮助:

  1. 在表单中添加一个 PrintDialog。

    2.将其属性设置为您的文档。

.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
        if (keyData == (Keys.Control | Keys.P)) {
            printDialog1.ShowDialog(this);
            return true;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }

【讨论】:

  • 嗨兄弟,我如何将 PrintDialog 的属性设置为 Report.rdlc
【解决方案2】:

首先加载main 这样做

Private Sub main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Me.KeyPreview = True
    
    End Sub

然后在KeyDown事件中编写代码

 If e.Control AndAlso e.KeyValue = Keys.P Then
    //somthing

     End If

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    • 1970-01-01
    • 2016-03-13
    • 2011-07-22
    相关资源
    最近更新 更多