Wrox Programmer Forums
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 31st, 2009, 06:33 PM
Registered User
 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Question How do I change printers?

I have just started using VB2008. I can’t get my program to print on anything but the default printer.
I select another printer in PrintDialog1.ShowDialog but the printing comes out on the default printer. How do I make use of the selected printer?
My code is:
Code:
       Try
            'Specify current page settings
            PrintDocument1.DefaultPageSettings = PrintPageSettings
            'Specify document for print dialog box and show
            StringToPrint = RichTextBox1.Text
            PrintDialog1.Document = PrintDocument1
            Dim result As DialogResult = PrintDialog1.ShowDialog()
            'If click OK, print document to printer
            If result = DialogResult.OK Then
                PrintDocument1.Print()
            End If
        Catch ex As Exception
            'Display error message
            MessageBox.Show(ex.Message)
        End Try
 
Old September 23rd, 2010, 12:52 AM
Registered User
 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
If result = DialogResult.OK Then
    PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
    PrintDocument1.Print()
End If





Similar Threads
Thread Thread Starter Forum Replies Last Post
List the Available printers ajit Java Basics 2 May 4th, 2007 07:54 AM
Add Printers ldoodle Classic ASP Basics 2 November 14th, 2006 09:20 AM
How to show all available printers name? vijaykumartaduri General .NET 1 October 13th, 2006 12:03 AM
Printing and printers neilsands Java Basics 1 May 4th, 2006 08:57 AM
Delete Printers Table Teqlump VB Databases Basics 1 September 10th, 2004 04:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.