使用 printform 组件选择打印机和设置页边距

Selecting printer and settings margins of page with printform component

如何添加打印机选择对话框,如何控制页边距? 我在代码中尝试了很多东西(打印文档代码有效,但它们不显示我的表格)但它们没有用。我正在使用此代码打印表单:

With Me.PrintForm1
    .PrintAction = Printing.PrintAction.PrintToPreview
    .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
End With

Me.Close()

它可以工作,但是它不要求选择打印机,而且我无法控制边距。

谢谢

我终于找到了解决办法,这里是:

PrintDialog1.PrinterSettings = PrintForm1.PrinterSettings
    PrintDialog1.AllowSomePages = True
    If PrintDialog1.ShowDialog = DialogResult.OK Then
        PrintForm1.PrinterSettings = PrintDialog1.PrinterSettings

        With Me.PrintForm1
            .PrintAction = Printing.PrintAction.PrintToPreview



            Dim MyMargins As New Margins

            With MyMargins
                .Left = 40
                .Right = 40
                .Top = 40
                .Bottom = 40
            End With

            .PrinterSettings.DefaultPageSettings.Margins = MyMargins

            PrintForm1.DocumentName = notasyon_lbl.Text
            .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)

        End With

    End If

谢谢。