Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,542 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,810 people online right now. Registration is fast and FREE... Join Now!




Save PageSettings

 
Reply to this topicStart new topic

Save PageSettings, This should be easy, but ....

HiArt
21 Aug, 2008 - 10:08 PM
Post #1

New D.I.C Head
*

Joined: 14 Apr, 2008
Posts: 9

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
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:38PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month