منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : طباعة ال data grid view
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
عملت كود لطباعة ال grid view لكن المشكلة انو ما بطبعلي البيانات اللي داخله وكذلك اذا في طريقة تطبعي كل ال grid view في صفحة واحده لانو بيعطيني اياه في اكثر من صفحة كونو الاعمدة اللي فيه عددها كبير
كود زر معاينة قبل الطباعة هو كالتالي :
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If (SetupThePrinting()) Then
Dim MyPrintPreviewDialog As PrintPreviewDialog
MyPrintPreviewDialog = New PrintPreviewDialog()

MyPrintPreviewDialog.Document = PrintDocument1
MyPrintPreviewDialog.ShowDialog()
End If
End Sub
"******************************************
Private Sub PrintDocument1_PrintPage1(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim more As Boolean
more = MyDataGridViewPrinter.DrawDataGridView(e.Graphics)
If more = True Then
e.HasMorePages = True
End If
End Sub
"**************************************************
Private Function SetupThePrinting() As Boolean
Dim MyPrintDialog As New PrintDialog()

MyPrintDialog.AllowCurrentPage = False
MyPrintDialog.AllowPrintToFile = False
MyPrintDialog.AllowSelection = False
MyPrintDialog.AllowSomePages = False
MyPrintDialog.PrintToFile = False
MyPrintDialog.ShowHelp = False
MyPrintDialog.ShowNetwork = False

If MyPrintDialog.ShowDialog() <> DialogResult.OK Then
Return False
End If

PrintDocument1.DocumentName = "الجرد السنوي"
PrintDocument1.PrinterSettings = MyPrintDialog.PrinterSettings
PrintDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings
PrintDocument1.DefaultPageSettings.Margins = New Margins(40, 40, 40, 40)

If MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
MyDataGridViewPrinter = New DataGridViewPrinter(DataGridView1, PrintDocument1, True, True, "معلومات المرضى", New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), _
Color.Black, True)
Else
MyDataGridViewPrinter = New DataGridViewPrinter(DataGridView1, PrintDocument1, False, True, "معلومات المرضى", New Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), _
Color.Black, True)
End If

Return True
End Function
"***************************************************
ما في حد عندو رد لهالموضوع