1
A
回答
2
对于打印我对话框,在这里是ReportViewer控件
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if ((e.Key == Key.P) && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
reportViewer.PrintDialog();
}
对于出口你也许可以使用reportViewer.ExportDialog使用这部分代码()
0
我只是结合了几个解决方案,并实现了这个解决方案。
将此代码放置在您的表单代码中,那个reportviewer就在那里。
public partial class frmReport : Form
{
public frmReportDevices()
{
InitializeComponent();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.P))
{
rpt.PrintDialog();
}
if (keyData == (Keys.F2))
{
string _sSuggestedName = String.Empty;
byte[] byteViewerPDF = rpt.LocalReport.Render("PDF");
byte[] byteViewerExcel = rpt.LocalReport.Render("Excel");
byte[] byteViewerWord = rpt.LocalReport.Render("Word");
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "PDF files (.pdf)|.pdf| Doc files (.doc)|.doc| Excel files (.xls)|.xls";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream newFile = new FileStream(saveFileDialog1.FileName, FileMode.Create);
if (saveFileDialog1.FilterIndex == 1)
{
newFile.Write(byteViewerPDF, 0, byteViewerPDF.Length);
newFile.Close();
}
else if (saveFileDialog1.FilterIndex == 2)
{
newFile.Write(byteViewerWord, 0, byteViewerWord.Length);
newFile.Close();
}
else if (saveFileDialog1.FilterIndex == 3)
{
newFile.Write(byteViewerExcel, 0, byteViewerExcel.Length);
newFile.Close();
}
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
相关问题
- 1. DevExpress报告工具栏没有选择报告查看器
- 2. 工具栏中的键盘快捷键
- 3. 工具栏中的酒吧按钮项底部的快捷栏
- 4. 错误工具栏报表查看器
- 5. 分配快捷键
- 6. 报告查看器IO的工具?
- 7. 查看/计划键盘快捷键的工具?
- 8. 报告查看器工具栏图标间隔过宽
- 9. 报告查看器不显示我分配的报告
- 10. 如何将快捷键分配给bindingNavigator上的按钮?
- 11. 在WPF中分配快捷键到按钮
- 12. 按钮的AIR键盘快捷键
- 13. 如何将§键分配为快捷键?
- 14. 分配键盘快捷键QML组件
- 15. Eclipse工具栏快捷方式
- 16. 报告查看器配置错误
- 17. 将键盘快捷键分配给Access 2007表单中的按钮
- 18. 如何添加更多快捷键到android studio工具栏?
- 19. Matplotlib - 导航工具栏快捷键不起作用
- 20. vb.net报告查看器多个报告
- 21. 按钮在HTML中触发快捷键
- 22. 如何为按钮制作快捷键
- 23. 为按钮指定快捷键 - Qt C++
- 24. 如何设置按钮的快捷键
- 25. 报告查看器如何工作?
- 26. 为仅作为键盘快捷键提供的命令添加Visual Studio工具栏按钮
- 27. nicEdit工具栏按钮部分可见
- 28. 工具栏中的分机js按钮
- 29. 工具提示快捷键文本
- 30. 禁用诊断工具快捷键