创建一组图纸以复制到页面中

时间:2018-08-03 18:57:52

标签: vb.net printing

我按照MS指南在绘图对象上编写了此代码 代码创建了一个标签,现在我想在打印页面内的3列8行中重复所有此对象

 Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage

    Dim drawFormat As New StringFormat
    drawFormat.Alignment = StringAlignment.Center

    Dim drawRect1 As New RectangleF(0, 60, 270, 20)
    Dim drawRect2 As New RectangleF(0, 80, 270, 20)
    Dim drawRect3 As New RectangleF(0, 115, 100, 20)
    Dim drawRect4 As New RectangleF(100, 110, 100, 30)
    Dim drawRect5 As New Rectangle(100, 110, 100, 30)


    e.Graphics.DrawString("OLD Code: " & TextBox2.Text, carattere, Brushes.Black, drawRect1, drawFormat)
    e.Graphics.DrawString("NEW Code: " & TextBox3.Text, carattere, Brushes.Black, drawRect2, drawFormat)
    e.Graphics.DrawString("Quantità", carattere, Brushes.Black, drawRect3, drawFormat)
    e.Graphics.DrawString(TextBox4.Text, New Font("Microsoft Sans Serif", 18, FontStyle.Regular), Brushes.Black, drawRect4, drawFormat)
    e.Graphics.DrawRectangle(New Pen(Brushes.Black), drawRect5)


    Dim newImage As Image = My.Resources.Immagine
    Dim x As Integer = 47
    Dim y As Integer = 5
    Dim width As Integer = 180
    Dim height As Integer = 50
    e.Graphics.DrawImage(newImage, x, y, width, height)

End Sub

那么,有一个我可以用来存储所有东西并重复的容器吗?还是我必须为所有标签写所有代码?

0 个答案:

没有答案