JohnWein

The only way I have been able to change the PaperSize displayed in the PrinterDialog or PageSetupDialog controls is to display the control and have the user change the Size. In code I have tried to change the PaperSize of the Document and both controls. When I display a control, the PaperSize is not changed. How can I change the displayed PaperSize

Edit: In the PrintPreviewControl, the PaperSize changes. That is, if I change the PaperSize from "Letter" to "Legal" the page displayed in the PrintPreviewControl changes, but the PaperSize displayed in the PageSetupDialog control stays at "Letter".



Re: Visual Basic Express Edition Programmatically change PrinterDialog or PageSetupDialog PaperSize?

Tall Dude

Imports system.drawing.Printing

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

Dim ps As PaperSize = _

PrintDocument1.PrinterSettings.PaperSizes.Item(ComboPaperSize.SelectedIndex)

PageSetupDialog1.PageSettings.PaperSize = ps

PageSetupDialog1.ShowDialog()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles MyBase.Load

' Add list of supported paper sizes found on the printer.

' The DisplayMember property is used to identify the property

' that will provide the display string.

ComboPaperSize.DisplayMember = "PaperName"

Dim pkSize As PaperSize

For i As Integer = 0 To PrintDocument1.PrinterSettings.PaperSizes.Count - 1

pkSize = PrintDocument1.PrinterSettings.PaperSizes.Item(i)

ComboPaperSize.Items.Add(pkSize)

Next

' Create a PaperSize and specify the custom paper size _

' through the constructor and add to combobox.

Dim pkCustomSize1 As New PaperSize("Custom Paper Size", 100, 200)

ComboPaperSize.Items.Add(pkCustomSize1)

ComboPaperSize.SelectedIndex = 3

End Sub

End Class






Re: Visual Basic Express Edition Programmatically change PrinterDialog or PageSetupDialog PaperSize?

JohnWein

Your code works and mine does too now. I inherit the PrintPreviewDialog control. I think I didn't have the document set on the PrintPreviewDialog.