2011-10-04 153 views
0

Winform應用程序包含一個帶有reportViewer控件的窗體。在初始化表單時生成報表,但是當我嘗試以編程方式在報表查看器上運行PrintDialog時,出現'由於對象當前狀態導致操作無效'的錯誤消息。在執行下一步操作之前請等待winform加載?

當我註釋掉PrintDialog行時,報表顯示正常。我認爲這個問題在產生表格/報告時是滯後的。在啓動PrintDialog之前有沒有辦法等到表單加載?

代碼摘錄:

this.reportViewer1.RefreshReport(); this.reportViewer1.PrintDialog();

UPDATE

解決方案是(的建議):

private void form_load(...) 
{ 
    createReport; 
    this.reportViewer1.RefreshReport(); 
} 

private void reportViewer1_RenderingComplete(...) 
{ 
    this.reportViewer1.PrintDialog(); 

} 

回答

相關問題