Help me to finish my complet Datagrid print

U

ucasesoftware

I have just a problem to margin the Datagrid... Could someone help me ?
the datragid always print in the top LEFT


#Region " Impression "

'Déclaration
Private PrintPageSettings As New
System.Drawing.Printing.PageSettings

Private Sub mnItemImprimer_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnItemImprimer.Click
printDirect()
End Sub

Private Sub mnItemApercu_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles mnItemApercu.Click
printPreview()
End Sub

Private Sub mnItemMiseEnPage_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles mnItemMiseEnPage.Click
printPageSetup()
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Try
Dim myArgs As New PaintEventArgs(e.Graphics, New
Rectangle(New Point(0, 0), Me.Size))
Select Case Me.ActiveMdiChild.Name
Case "boitesAuxLettres"

Me.InvokePaint(myForms.formBoitesAuxLettres.EasyDataGrid1, myArgs)
End Select
Catch ex As Exception
monErreur(ex)
End Try

End Sub

Private Sub printDirect()
PrintDocument1.Print()
End Sub

Private Sub printPreview()
Try
PrintDocument1.DefaultPageSettings = PrintPageSettings
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
Catch ex As Exception
monErreur(ex)
End Try
End Sub


Private Sub printPageSetup()
Try
PageSetupDialog1.PageSettings = PrintPageSettings
Dim Result1 As DialogResult = PageSetupDialog1.ShowDialog()
If Result1 = DialogResult.OK Then
'To Print
Try

PrintDocument1.DefaultPageSettings =
PrintPageSettings

PrintDialog1.Document = PrintDocument1
Dim Result As DialogResult =
PrintDialog1.ShowDialog
If Result = DialogResult.OK Then
PrintDocument1.Print()
End If
Catch ex As Exception
monErreur(ex)
End Try
End If
Catch ex As Exception
monErreur(ex)
End Try


End Sub
#End Region
 
T

Thomas Wenning

I have just a problem to margin the Datagrid... Could someone help me ?
the datragid always print in the top LEFT
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Try
Dim myArgs As New PaintEventArgs(e.Graphics, New
Rectangle(New Point(0, 0), Me.Size))
Select Case Me.ActiveMdiChild.Name
Case "boitesAuxLettres"

Me.InvokePaint(myForms.formBoitesAuxLettres.EasyDataGrid1, myArgs)
End Select
Catch ex As Exception
monErreur(ex)
End Try

End Sub

Hi,

i am not so sure, but i think you can set the margin like this:

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage


e.PageSettings.Margins.Bottom = 100 'and so on ....
e.PageSettings.Margins.Top = 100

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top