I want to provide a Print Setup and page setup menu items in my app but do not know how to set the printing setting on the GoView control.
Ideally I would like to do osomething like:
Dim pd As New PrintDocument
Dim dlg As New PageSetupDialog
dlg.Document = pd
If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
GoView.PrintDocument = pd
End If
There is the GoView.PrintShowDialog that sounds likt it does what I want but isot accessible in my main form
Is there an example in the sample apps, I can;t find one in Demo1 ??
These seem to show how to get the printdocument settings but don;t help with defining the pagesettings used by the goview itself when I use the printpreview or print methods.
Is there a way of setting the printsettings that are used by the goview printdocument object when it is printing?
I have tried the following, but it seems to have no imapct on the printpreview display!
Public Overrides Sub PrintDocumentPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
e.PageSettings.Landscape = True
MyBase.PrintDocumentPage(sender, e)
End Sub
Many thanks for this, My brain was stuck on a single minded approach to the problem! I just needed to get my head around a differant approach. I think I have got what I want with the following Inherited GoView object which I can then call the PageSetup to define the PageSettings!
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports Northwoods.Go
Namespace NMTGo
Public Class NMTGoView
Inherits GoView
Private pgSet As New PageSettings
Protected Overrides Function PrintShowDialog(ByVal pd As PrintDocument) As DialogResult
pd.DefaultPageSettings = pgSet
Return MyBase.PrintShowDialog(pd)
End Function
Protected Overrides Sub PrintPreviewShowDialog(ByVal pd As PrintDocument)
pd.DefaultPageSettings = pgSet
MyBase.PrintPreviewShowDialog(pd)
End Sub
Public Function PageSetup() As DialogResult
Dim dlg As New PageSetupDialog
dlg.PageSettings = pgSet
Return dlg.ShowDialog
End Function
End Class
End Namespace
I thought for those newbies like me out there this might be helpful. If you do as Tom shows above this code will show you how to get a landscape print automatically without first running a page setup, on the form that you put your inherited GoView on (I called my inherited GoView govMain in this case):
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim MyPageSettings As New PageSettings
MyPageSettings.Landscape = True
govMain.PGSet = MyPageSettings
End Sub
Here is the code for my inherited GoView with pagesetup dialog:
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports Northwoods.Go
Public Class MyGoView
Inherits GoView
Private _pgSet As New PageSettings
Protected Overrides Function PrintShowDialog(ByVal pd As PrintDocument) As DialogResult
pd.DefaultPageSettings = _pgSet
Return MyBase.PrintShowDialog(pd)
End Function
Protected Overrides Sub PrintPreviewShowDialog(ByVal pd As PrintDocument)
pd.DefaultPageSettings = _pgSet
MyBase.PrintPreviewShowDialog(pd)
End Sub
Public Function PageSetup() As DialogResult
Dim dlg As New PageSetupDialog
dlg.PageSettings = _pgSet
Return dlg.ShowDialog
End Function
Public Property PGSet() As PageSettings
Get
PGSet = _pgSet
End Get
Set(ByVal value As PageSettings)
_pgSet = value
End Set
End Property
End Class