📄 form1.vb
字号:
Imports System.Drawing.Printing
Public Class Form1
Private WithEvents m_PrintDocument As PrintDocument
' Print now.
Private Sub btnPrintNow_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnPrintNow.Click
m_PrintDocument = New PrintDocument
m_PrintDocument.Print()
End Sub
' Display a print preview dialog.
Private Sub btnPrintPreview_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnPrintPreview.Click
m_PrintDocument = New PrintDocument
dlgPrintPreview.Document = m_PrintDocument
dlgPrintPreview.ShowDialog()
End Sub
' Display a print dialog.
Private Sub btnPrintDialog_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnPrintDialog.Click
m_PrintDocument = New PrintDocument
dlgPrint.Document = m_PrintDocument
dlgPrint.ShowDialog()
End Sub
' Print a page with a diamond on it.
Private Sub m_PrintDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles m_PrintDocument.PrintPage
Dim pts() As Point = { _
New Point(e.MarginBounds.Left + e.MarginBounds.Width \ 2, _
e.MarginBounds.Top), _
New Point(e.MarginBounds.Right, _
e.MarginBounds.Top + e.MarginBounds.Height \ 2), _
New Point(e.MarginBounds.Left + e.MarginBounds.Width \ 2, _
e.MarginBounds.Bottom), _
New Point(e.MarginBounds.Left, _
e.MarginBounds.Top + e.MarginBounds.Height \ 2) _
}
Using the_pen As New Pen(Color.Black, 10)
e.Graphics.DrawPolygon(the_pen, pts)
End Using
e.HasMorePages = False
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -