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. 禁用診斷工具快捷鍵