index > Visual C# General > How to print ?

How to print ?

I edit my print codes. but I found it didnt work. I don't know why. Please give me some suggestions. Thanks.

--------------------------------------------------------------------

private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
PrintDialog Myprint = new PrintDialog();
Myprint.Document = printDocument1;
if (printDialog1.ShowDialog()==DialogResult.OK)
try
{
printDocument1.Print();
}
catch{
printDocument1.PrintController.OnEndPrint(printDocument1,new System.Drawing.Printing.PrintEventArgs());
}
}




Frank
Frank722

Hi frank,

I'm not sure if its because you made a typo copying the code to this forum but it looks like you have created two PrintDialog controls.

You created a new PrintDialog here

PrintDialog Myprint = new PrintDialog();

and then you referance printDialog1 in the if statement, you also fail to call the Myprint option.

Like I said I'm not sure (I'm kind of new to this myself).

Scott




We all have to start some place - I just don't know where yet!
ScottMcKeown

Not above reason.Thanks. I have solve all the problems.Because I dont edit print page events fuction.

I made a mistake. I look up some books. Before printdocument.print() is running, print page events fuction should be called.




Frank
Frank722
reply 3

You can use google to search for other answers

 

More Articles

• attempting to use an array across a class
• Calculator
• ShowHelp dispose of browsers
• Save
• Component licensing How do I?
• why the format is not uniform
• "Uable to cast object type" exception in VS2005
• How can I get data from Excel file by C# ?
• how to get the temporature from this webservice?
• BackgroundWorker and SHGetFileInfo
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Creating a Wizard-Style Application
• Deleting Control form my from
• Message Box
• add one tracelistener to all tracesources
• Accessing Controls on a splitter panel
• How to create web page shorcut in a Setu
• Redirecting STDOUT and STDERR from a DLL
• Regular Expression syntax for C#
• Searching Text or Unicode strings
• Working with Certificate Revocation List
• Breakpoints, C# IDE Express Edition
• Interrupts
• web user control and its files
• IE Extensions
• Is it possible to Add Domain and Compute

Hot Articles

• Need to locate a child control out of th
• Using multiple forms
• Printing & Exporting
• How to get UserId of a logined user from
• Call C# script from within another C# sc
• 101 Samples problems with final release
• Sending mail with C#
• Error: Invoke or BeginInvoke cannot be c
• missing data sources
• How to support selectable and non-select
• How to load a textbox?
• string to hash
• String literal problem
• Returning correct Properties from Underl
• Problems with .Net Remoting

Recommend Articles

• Accessing the Windows Scheduler
• I Need A Smple For Receiving SMS In Side
• RichTextBox : Text color
• Best Practices
• Regarding WebBrowser Control
• communication between threads
• OTP Java script error
• Saving Connection Strings
• How to know because of which control eve
• asynchronously or synchronously?
• separate classes
• Read a file in a window !!!
• Is Vista mostly C# .NET?
• Setting the position of a MessageBox
• Error Connecting to Database