Impression inversé d'une DataGrid
Re Bonjour les amis
Mon problème aujourd’hui c'est l’impression inversé d'une DataGrid. Résumant un peut, j'ai un DataGrid remplie à partir de la Base de donnée et qui s'affiche correctement de droite à gauche (les données s'affichent en Arabe), tout est parfait pour le moment (colonne(0), colonne(1), colonne(2), colonne(3))
Le problème c'est lors de l'impression que les champs s'inversent (colonne(3), colonne(2), colonne(1), colonne(0)).
voila mon code à rectifier s'il le faut
Code:
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 54 55 56 57 58 59 60 61 62
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'------------------------- Choix de l'imprimante ----------------------
'Dim dlg As New PrintDialog
'dlg.Document = PrintDocument1
'Dim result As DialogResult = dlg.ShowDialog() = PrintPreviewDialog1.ShowDialog()
'If (result = System.Windows.Forms.DialogResult.OK) Then
' PrintDocument1.Print()
'End If
'---------------------------------------------------------------------
'-------------- visualisation du document Avant Impression ------------
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.PrintPreviewControl.Zoom = 1.1
AddHandler PrintDocument1.PrintPage, AddressOf PrintDocument1_PrintPage
PrintPreviewDialog1.WindowState = FormWindowState.Maximized
PrintPreviewDialog1.ShowDialog()
'--------------------------------------------------------------------------
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
With DataGridView1
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.SetDigitSubstitution(New Globalization.CultureInfo("Ar").LCID, StringDigitSubstitute.National)
fmt.FormatFlags = StringFormatFlags.DirectionRightToLeft
fmt.Trimming = StringTrimming.EllipsisCharacter
fmt.LineAlignment = StringAlignment.Near
Dim y As Single = e.MarginBounds.Top
Do While mRow < .RowCount - 1
Dim row As DataGridViewRow = .Rows(mRow)
Dim x As Single = e.MarginBounds.Left
Dim h As Single = 0
For Each cell As DataGridViewCell In row.Cells
Dim rc As RectangleF = New RectangleF(x, y, cell.Size.Width, cell.Size.Height)
e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width, rc.Height) ' Cadriage du tableau
If (newpage) Then
e.Graphics.DrawString(DataGridView1.Columns(cell.ColumnIndex).HeaderText, .Font, Brushes.Black, rc, fmt)
Else
e.Graphics.DrawString(DataGridView1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), .Font, Brushes.Black, rc, fmt)
End If
x += rc.Width 'espacement entre les colones de 1.1
h = Math.Max(h, rc.Height) 'espacement entre les lignes de 1.1
'x += 1.1 * rc.Width 'espacement entre les colones de 1.1
'h = Math.Max(h, rc.Height) * 1.1 'espacement entre les lignes de 1.1
Next
newpage = False
y += h
mRow += 1
If y + h > e.MarginBounds.Bottom Then
e.HasMorePages = True
mRow -= 1
newpage = True
Exit Sub
End If
Loop
mRow = 0
End With
End Sub |
Remarque: Le code fonctionne bien pour les informations Latin
Mes champs ( CIN , PreNom , Nom , Date de naissance)
Merci.:java: