Solved

Default Printer

Posted on 2004-10-13
2
201 Views
Last Modified: 2010-04-15
How do I print to the default printer..............based upon this code.........what would I change i the code?



private void buttonPrintSearchResults_Click(object sender, System.EventArgs e)
            {
                  try
                  {
                        string use_printer="";

                        DataSet ds = this.GenerateInternalDataSet(this.textBoxSearchString.Text);                        
                        OnExportGridToCSV(ds);

                        this.richTextBoxSearchExport.LoadFile(@"C:\search_export.txt", RichTextBoxStreamType.PlainText);

                        foreach(string p_rinter in PrinterSettings.InstalledPrinters)
                        {
                              use_printer = p_rinter;
                        }

                        PrintDocument pd = new PrintDocument();
                        pd.PrinterSettings.PrinterName = use_printer;
                        pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                        pd.Print();
                  }
                  catch(Exception ee)
                  {
                        System.Diagnostics.Debug.WriteLine(ee);
                  }

            }

            private void pd_PrintPage(object sender, PrintPageEventArgs ev)
            {
                  Graphics g = ev.Graphics;
                  Font font = new Font("Arial", 16);
                  SolidBrush brush = new SolidBrush(Color.Black);

                  g.DrawString(this.richTextBoxSearchExport.Text,font, brush, new Rectangle(20,20,200,100));
            }
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
a_goat earned 500 total points
ID: 12301268
Just don't set the PrinterName.  It'll automatically print to the default printer using the default printer settings.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 12302659
You are correct.  I needed to not set it.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question