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. 工具欄中的鍵盤快捷鍵
- 2. 工具欄中的酒吧按鈕項底部的快捷欄
- 3. 錯誤工具欄報表查看器
- 4. 分配快捷鍵
- 5. 查看/計劃鍵盤快捷鍵的工具?
- 6. 報告查看器工具欄圖標間隔過寬
- 7. 報告查看器不顯示我分配的報告
- 8. 在WPF中分配快捷鍵到按鈕
- 9. 如何將快捷鍵分配給bindingNavigator上的按鈕?
- 10. 將鍵盤快捷鍵分配給Access 2007表單中的按鈕
- 11. Matplotlib - 導航工具欄快捷鍵不起作用
- 12. vb.net報告查看器多個報告
- 13. 爲按鈕指定快捷鍵 - Qt C++
- 14. 爲僅作爲鍵盤快捷鍵提供的命令添加Visual Studio工具欄按鈕
- 15. 工具提示快捷鍵文本
- 16. IE開發工具去行快捷鍵
- 17. 如何分配Control +。作爲快捷鍵?
- 18. 在WPF Ribbon Button中分配快捷鍵
- 19. SAP古典輸出報告重新分配標準工具欄按鈕/向下滾動頁面
- 20. 幫助報告查看器
- 21. 報告查看器打印?
- 22. 報告查看器問題
- 23. 報告查看器與httpOnlyCookies
- 24. 如何在運行時將TAction分配給工具欄按鈕?
- 25. 在PhpStorm中顯示/隱藏工具按鈕的快捷鍵是什麼?
- 26. 工具欄按鈕樣式
- 27. Swing工具欄按鈕
- 28. Excel的工具欄按鈕
- 29. UINavigationController工具欄按鈕
- 30. 是否可以將快捷按鈕添加到VS11工具欄以指向PowerShell腳本/命令?