PDA

View Full Version : کد پرینت کردن در richtextbox



msenator
چهارشنبه 10 بهمن 1386, 02:32 صبح
کد پرینت کردن در richtextbox را می خوام اگه می تونید کمک کنید این کد را نوشتم صفحه پرینت باز می شود ولی برنامه قفل می شود
printToolStripMenuItem_Click(sender, e);
// Declare an object for the PrintDocument class
PrintDocument objPrintDocument = new PrintDocument();
// Set the DocumentName property
objPrintDocument.DocumentName = "Text File PrintDemo";
// Set the PrintDialog properties
printDialog1.AllowPrintToFile = false;
printDialog1.AllowSelection = false;
printDialog1.AllowSomePages = false;
// Set the Document property for
// the objPrintDocument object
printDialog1.Document = objPrintDocument;
// Show the Print dialog
if (printDialog1.ShowDialog() == DialogResult.OK)
{
// If the user clicked on the OK button
// then set the StreamReader object to
// the file name in the strFileName variable
objStreamToPrint = new StreamReader(strFileName);
// Set the printer font
objPrintFont = new Font("Arial", 10);
// Set the PrinterSettings property of the
// objPrintDocument Object to the
// PrinterSettings property returned from the
// PrintDialog control
objPrintDocument.PrinterSettings =
printDialog1.PrinterSettings;
// Add an event handler for the PrintPage event

// the objPrintDocument object
objPrintDocument.PrintPage +=new PrintPageEventHandler(prtPage);
// Print the text file
objPrintDocument.Print();
// Clean up
objStreamToPrint.Close();
objStreamToPrint = null;

MH2538
چهارشنبه 10 بهمن 1386, 09:02 صبح
به این آدرس مراجعه کن.
http://support.microsoft.com/kb/812425