1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| Dim policeS As New Font("Arial", 10)
Dim policeT As New Font("Arial", 10)
Dim policeG As New Font("Arial", 10, FontStyle.Bold)
Dim XPos, YPos As Single
Dim Interligne As Single
Dim ChaineImpr As String = ""
Dim TailleChaine As SizeF
Using MyGr As Graphics = e.Graphics
XPos = e.MarginBounds.Width / 2.0F
YPos = 0
Dim LargCol(3), PosCol(3) As Single
LargCol(3) = MyGr.MeasureString("Prix Unitaire HT", policeS).Width
LargCol(2) = MyGr.MeasureString("Quantité", policeS).Width
LargCol(1) = MyGr.MeasureString("Désignation", policeS).Width
LargCol(0) = e.MarginBounds.Width / 2.0F - LargCol(1) - LargCol(2) - LargCol(3)
For cmpt As Int32 = 1 To 3
PosCol(cmpt) = PosCol(cmpt - 1) + LargCol(cmpt - 1)
Next
Dim FormatTitre As New StringFormat
FormatTitre.Alignment = StringAlignment.Center
FormatTitre.LineAlignment = StringAlignment.Center
Dim FormatCase As New StringFormat
' Impression Des Titres
MyGr.FillRectangle(Brushes.Blue, XPos, YPos, e.MarginBounds.Width / 2.0F, Interligne)
MyGr.DrawString("Code Article", policeS, Brushes.White, New RectangleF(PosCol(0), YPos, LargCol(0), Interligne), FormatTitre)
MyGr.DrawRectangle(Pens.Black, PosCol(0), YPos, LargCol(0), Interligne)
MyGr.DrawString("Désignation", policeS, Brushes.White, New RectangleF(PosCol(1), YPos, LargCol(1), Interligne), FormatTitre)
MyGr.DrawRectangle(Pens.Black, PosCol(1), YPos, LargCol(1), Interligne)
MyGr.DrawString("Quantité", policeS, Brushes.White, New RectangleF(PosCol(2), YPos, LargCol(2), Interligne), FormatTitre)
MyGr.DrawRectangle(Pens.Black, PosCol(2), YPos, LargCol(2), Interligne)
MyGr.DrawString("Prix Unitaire HT", policeS, Brushes.White, New RectangleF(PosCol(3), YPos, LargCol(3), Interligne), FormatTitre)
MyGr.DrawRectangle(Pens.Black, PosCol(3), YPos, LargCol(3), Interligne)
YPos += Interligne
For cmptLigne As Int32 = 0 To Me.DataGridView1.RowCount - 1
For cmptCol As Int32 = 0 To 3
If cmptCol = 0 Then
ChaineImpr = Me.DataGridView1.Item(cmptCol + 1, cmptLigne).Value.ToString
TailleChaine = MyGr.MeasureString(ChaineImpr, policeT, CInt(LargCol(0)))
MyGr.DrawString(ChaineImpr, policeT, Brushes.Black, New RectangleF(PosCol(0), YPos, CInt(LargCol(0)), TailleChaine.Height))
MyGr.DrawRectangle(Pens.Black, PosCol(0), YPos, CInt(LargCol(0)), TailleChaine.Height)
Else
MyGr.DrawString(Me.DataGridView1.Item(cmptCol + 1, cmptLigne).Value.ToString, policeT, Brushes.Black, New RectangleF(PosCol(cmptCol), YPos, CInt(LargCol(cmptCol)), TailleChaine.Height))
MyGr.DrawRectangle(Pens.Black, PosCol(cmptCol), YPos, CInt(LargCol(cmptCol)), TailleChaine.Height)
End If
Next
YPos += TailleChaine.Height
Next
End Using |
Partager