我正在使用Visual Studio 2008,.net Framework 3.5進行Windows窗體客戶端服務器應用程序的開發。當我運行程序並嘗試打印時會出現一個奇怪的錯誤。打印對話框打開,但我必須單擊確定按鈕兩次才能正常工作。第二次點擊後,它工作正常,沒有錯誤。當我把斷點放在:if(result == DialogResult.OK)時,直到第二次點擊纔會觸發斷點。這裏是代碼:C#Windows窗體打印對話框單擊確定兩次以迴應
private void tbPrint_Click(object sender, EventArgs e)
{
try
{
printDialog1.Document = pDoc;
DialogResult result = printDialog1.ShowDialog();
if (result == DialogResult.OK)
{
pDoc.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
pDoc.Print();
}
...
這讓我瘋狂,我看不到任何會干擾它的東西。
當您應該將結果作爲DialogResult.OK發送出去時,您能向我們展示printDialog中的代碼嗎? – 2010-04-15 21:11:37
這是密封的printDialog。 – sbartlett 2010-04-16 17:18:26