ElseIf oColumnTypes(i) Is GetType(DataGridViewCheckBoxColumn) Then
oCheckbox.Size = New Size(14, 14)
oCheckbox.Checked = CType(oCell.Value, Boolean)
Dim oBitmap As New Bitmap(oColumnWidths(i), nHeight)
Dim oTempGraphics As Graphics = Graphics.FromImage( _
oBitmap)
oTempGraphics.FillRectangle(Brushes.White, New _
Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
oCheckbox.DrawToBitmap(oBitmap, New Rectangle(CType(( _
oBitmap.Width - oCheckbox.Width) / 2, Int32), CType(( _
oBitmap.Height - oCheckbox.Height) / 2, Int32), _
oCheckbox.Width, oCheckbox.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts( _
i), nTop))
ElseIf oColumnTypes(i) Is GetType( _
DataGridViewComboBoxColumn) Then
oComboBox.Size = New Size(oColumnWidths(i), nHeight)
Dim oBitmap As New Bitmap(oComboBox.Width, _
oComboBox.Height)
oComboBox.DrawToBitmap(oBitmap, New Rectangle(0, 0, _
oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts( _
i), nTop))
e.Graphics.DrawString(oCell.Value.ToString, _
oCell.InheritedStyle.Font, New SolidBrush( _
oCell.InheritedStyle.ForeColor), New RectangleF( _
oColumnLefts(i) + 1, nTop, oColumnWidths(i) - 16, _
nHeight), oStringFormatComboBox)
ElseIf oColumnTypes(i) Is GetType(DataGridViewImageColumn) _
Then
Dim oCellSize As Rectangle = New Rectangle(oColumnLefts( _
i), nTop, oColumnWidths(i), nHeight)
Dim oImageSize As Size = CType(oCell.Value, Image).Size
e.Graphics.DrawImage(oCell.Value, New Rectangle( _
oColumnLefts(i) + CType(((oCellSize.Width - _
oImageSize.Width) / 2), Int32), nTop + CType((( _
oCellSize.Height - oImageSize.Height) / 2), Int32), _
CType(oCell.Value, Image).Width, CType(oCell.Value, _
Image).Height))
End If
e.Graphics.DrawRectangle(Pens.Black, New Rectangle( _
oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
i += 1
Next
End If
nRowPos += 1
nRowsPerPage += 1
Loop
DrawFooter(e, nRowsPerPage)
e.HasMorePages = False
End Sub
Private Sub DrawFooter(ByVal e As _
System.Drawing.Printing.PrintPageEventArgs, ByVal RowsPerPage As Int32)
Dim sPageNo As String = "Seite " & nPageNo.ToString
'Seiteneinstellung checken
If e.PageSettings.Margins.Top < 10 Then e.PageSettings.Margins.Top = 10
If e.PageSettings.Margins.Bottom < 10 Then _
e.PageSettings.Margins.Bottom = 10
'Abstand unten holen
Dim unten As Integer = e.PageSettings.Margins.Bottom - 15
' Right Align - User Name
e.Graphics.DrawString(sUserName, ESchriftart, Brushes.Black, _
e.MarginBounds.Left + (e.MarginBounds.Width - _
e.Graphics.MeasureString(sPageNo, ESchriftart, _
e.MarginBounds.Width).Width - 135), e.MarginBounds.Top + _
e.MarginBounds.Height - unten)
' Left Align - Date/Time
e.Graphics.DrawString(Now.ToLongDateString + " " + _
Now.ToShortTimeString, ESchriftart, Brushes.Black, _
e.MarginBounds.Left, e.MarginBounds.Top + e.MarginBounds.Height - _
unten)
' Center - Page No. Info
e.Graphics.DrawString(sPageNo, ESchriftart, Brushes.Black, _
e.MarginBounds.Left + (e.MarginBounds.Width - _
e.Graphics.MeasureString(sPageNo, ESchriftart, _
e.MarginBounds.Width).Width) / 2, e.MarginBounds.Top + _
e.MarginBounds.Height - unten)
End Sub |