You are on page 1of 2

Public Class FormLaporanBarangMasuk

Private Sub FormLaporanBarangMasuk_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Call TampilLaporanDataBarangMasuk()
End Sub

Private Sub BtnPrivew_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BtnPrivew.Click
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.Width = FormWindowState.Maximized
PrintDocument1.DefaultPageSettings.Landscape = True
PrintPreviewDialog1.PrintPreviewControl.Zoom = 1
PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As


System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim xPos As Single = 0
Dim count As Single = 0
Dim awal, akhir As Single
Dim line As String = Nothing
Dim leftMargin As Single = e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top
Dim myFont As Font = DGVLaporanDataBarangMasuk.Font
linesPerPage = e.MarginBounds.Height / myFont.Height()
Dim i As Integer
e.Graphics.DrawString("DATA BARANG MASUK", _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(0 * myFont.Height)), (topMargin + (count * myFont.Height)))
count = count + 2
e.Graphics.DrawRectangle(Pens.Black, leftMargin, _
topMargin + (count * myFont.Height), 630, 1)
count = count + 1
e.Graphics.DrawString("No.", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (0 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
e.Graphics.DrawString("No. Faktur", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (3 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
e.Graphics.DrawString("Tgl. Faktur", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (10 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
e.Graphics.DrawString("Id Barang", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (20 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
e.Graphics.DrawString("Jumlah Barang", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (26 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
e.Graphics.DrawString("Id Pemasok", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (34 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
e.Graphics.DrawString("Id Pemakai", DGVLaporanDataBarangMasuk.Font, _
Brushes.Black, (leftMargin + (41 * myFont.Height)), _
(topMargin + (count * myFont.Height)))
count = count + 2
e.Graphics.DrawRectangle(Pens.Black, leftMargin, topMargin + (count *
myFont.Height), 630, 1)
count = count + 1

awal = 1
akhir = DGVLaporanDataBarangMasuk.RowCount - 1
For i = 0 To DGVLaporanDataBarangMasuk.RowCount - 1
yPos = (topMargin + (count * myFont.Height))
If awal <= akhir Then
e.Graphics.DrawString(awal, DGVLaporanDataBarangMasuk.Font,
Brushes.Black, _
(leftMargin + (0 * myFont.Height)), yPos + 1)
End If
e.Graphics.DrawString(DGVLaporanDataBarangMasuk.Item(0, i).Value, _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(3 * myFont.Height)), yPos)
e.Graphics.DrawString(DGVLaporanDataBarangMasuk.Item(1, i).Value, _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(10 * myFont.Height)), yPos)
e.Graphics.DrawString(DGVLaporanDataBarangMasuk.Item(2, i).Value, _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(20 * myFont.Height)), yPos)
e.Graphics.DrawString(DGVLaporanDataBarangMasuk.Item(3, i).Value, _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(26 * myFont.Height)), yPos)
e.Graphics.DrawString(DGVLaporanDataBarangMasuk.Item(4, i).Value, _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(34 * myFont.Height)), yPos)
e.Graphics.DrawString(DGVLaporanDataBarangMasuk.Item(5, i).Value, _
DGVLaporanDataBarangMasuk.Font, Brushes.Black, (leftMargin + _
(41 * myFont.Height)), yPos)
count += 1
awal += 1
Next
e.Graphics.DrawRectangle(Pens.Black, leftMargin, _
topMargin + (count * myFont.Height), 630, 1)
End Sub

Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BtnKeluar.Click
Close()
End Sub
End Class

You might also like