Hi Folks,
this should be easy, but I am struggling with this.
I want to save Page Settings such as orientation, paper size, margins, etc so that the user doesn't have to change these every time they start the application. Here is the code I have tried; it attempts to save the settings to my.settings but it doesn't restore the settings. In my.settings I set an entry as type system.drawing,printing.pagesettings to accept the settings.
CODE
Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles PrintToolStripMenuItem.Click
Me.PrintDocument1.DefaultPageSettings = My.Settings.PageSettings
Me.PrintDocument1.Print()
End Sub
Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles PrintPreviewToolStripMenuItem.Click
Try
Dim dlg As New PrintPreviewDialog()
Me.PrintDocument1.DefaultPageSettings = My.Settings.PageSettings
dlg.Document = PrintDocument1
dlg.ShowDialog()
Catch ex As Exception
Call dbg.Warn(em.errMessage, ex.Message)
Process.GetCurrentProcess.Kill()
End Try
End Sub
Private Sub PageSetupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageSetupToolStripMenuItem.Click
Dim psDlg As New PageSetupDialog
Try
psDlg.PageSettings = My.Settings.PageSettings
psDlg.AllowMargins = False
psDlg.AllowPaper = True
psDlg.AllowPrinter = True
psDlg.Document = PrintDocument1
psDlg.ShowDialog()
My.Settings.PageSettings = psDlg.PageSettings
My.Settings.Save()
Catch ex As Exception
Call dbg.Warn(em.errMessage, ex.Message)
Process.GetCurrentProcess.Kill()
End Try
End Sub
There's probably an easy way to do this, but I seem to like difficult!
Anyway, thanks for the help
Art