JayBeeOH

TxtEditor - File Print Option - PrintDialog

Apr 14th, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.95 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
  8. '
  9. '                 Copyright © 2015. All rights reserved.
  10. '        All trademarks remain the property of their respective owners.
  11. '-------------------------------------------------------------------------------------------
  12. ' Program Name:   Text Editor
  13. '
  14. ' Author:         Joseph L. Bolen
  15. ' Date Created:   Feb 2015
  16. '
  17. ' Description:    Simple plain text editor program with printing ability.
  18. '
  19. '                 Documentation is at:
  20. '                   App's screen image is at: http://imgur.com/TzWs9kO
  21. '                   App's screen design time specs at: http://pastebin.com/bhinRQ5d
  22. '                   App's Visual Basic .NET Event Procedures & TODO's is at
  23. '                       http://pastebin.com/UZ4tcEpE
  24. '                   App's Visual Basic .NET code is at http://pastebin.com/u/jaybeeoh
  25. '                   Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
  26. '-------------------------------------------------------------------------------------------
  27.  
  28.     ' File Print option.
  29.     Private Sub PrintToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  30.         Handles PrintToolStripMenuItem.Click,
  31.                 PrintToolStripButton.Click
  32.  
  33.         With PrintDialog1
  34.             .PrinterSettings = PrintDocument1.PrinterSettings
  35.             .Document = PrintDocument1
  36.  
  37.             ' Allow the user to select a range of pages to be printed.
  38.             .AllowSomePages = True
  39.             .PrinterSettings.MinimumPage = 1
  40.             .PrinterSettings.MaximumPage = 9999
  41.             .PrinterSettings.FromPage = 1
  42.             .PrinterSettings.ToPage = 9999
  43.  
  44.             If DialogResult.OK = .ShowDialog() Then
  45.                 PrintDocument1.PrinterSettings = .PrinterSettings
  46.                 Try
  47.                     PrintDocument1.Print()
  48.                 Catch ex As InvalidPrinterException
  49.                     MessageBox.Show(ex.Message, "Invalid Printer",
  50.                                     MessageBoxButtons.OK,
  51.                                     MessageBoxIcon.Error)
  52.                 Catch ex As Exception
  53.                     MessageBox.Show("There was a problem printing the file." &
  54.                                     ControlChars.NewLine & ex.Message,
  55.                                    "Printing File Error",
  56.                                    MessageBoxButtons.OK,
  57.                                    MessageBoxIcon.Error)
  58.                 End Try
  59.             End If
  60.         End With
  61.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment