تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] سؤال عن استخدام e.HasMorePages = True
#1
[صورة مرفقة: salam.png]
ارجو من الزملاء الكرام توضيح فكرة اضافة صفحة عند استخدام اداة PrintDocument
وكيفية تحديد صفحه معينه وتوجيه جزء من النص لها مثلا في حالة طباعة داتا جريد على اكثر من صفحه
احتاج مثلا طباعة عنوان في الصفحه الاولى 
وطباعة جمله للصفحه الثانيه او الأخيره مثلا
بصفه عامه افهم كيف اتعامل مع صفحه واحده من حيث الكتابه في موقع معين لكن عندما احتاج أكثر من صفحه
فإنني لا افهم آليه عملها او التعامل معها برمجيا
لذا ارجو توضيح فكرة عملها بصفه عامة (من حيث طريقة وموقع اضافة e.HasMorePages = True )
وخاصة
مثلا عند الحاجه في التعامل مع مثل هذا الكود  اذا احتاج اكثر من صفحه 


Dim CellTopPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Top

    For Row = 0 To DataGridView1.RowCount - 1

        Dim CellLeftPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Left

        For Cell = 0 To DataGridView1.ColumnCount - 1

            Dim CellValue As String = DataGridView1.Rows(Row).Cells(Cell).Value.ToString()
            Dim CellWidth = DataGridView1.Rows(Row).Cells(Cell).Size.Width + 50
            Dim CellHeight = DataGridView1.Rows(Row).Cells(Cell).Size.Height

            Dim Brush As New SolidBrush(Color.Black)
            e.Graphics.DrawString(CellValue, New Font("Century Gothic", 10), Brush, CellLeftPos, CellTopPos)
            e.Graphics.DrawRectangle(Pens.Black, CellLeftPos, CellTopPos, CellWidth, CellHeight)

            CellLeftPos += CellWidth
        Next

        CellTopPos += DataGridView1.Rows(Row).Cells(0).Size.Height
الرد }}}
تم الشكر بواسطة:
#2
تفضل التعديل على أن تضع Row=0 قبل كل طباعة
PHP كود :
Dim Row As Integer 0

Private Sub PrintDocument1_PrintPage(sender As ObjectAs Printing.PrintPageEventArgsHandles PrintDocument1.PrintPage

    Dim CellTopPos 
As Integer PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Top

    
For 0 To 19 ' عدد الأسطر 20 لكل صفحة

        Dim CellLeftPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Left

        For Cell = 0 To DataGridView1.ColumnCount - 1

            Dim CellValue As String = DataGridView1.Rows(Row).Cells(Cell).Value.ToString()
            Dim CellWidth = DataGridView1.Rows(Row).Cells(Cell).Size.Width + 50
            Dim CellHeight = DataGridView1.Rows(Row).Cells(Cell).Size.Height

            Dim Brush As New SolidBrush(Color.Black)
            e.Graphics.DrawString(CellValue, New Font("Century Gothic", 10), Brush, CellLeftPos, CellTopPos)
            e.Graphics.DrawRectangle(Pens.Black, CellLeftPos, CellTopPos, CellWidth, CellHeight)

            CellLeftPos += CellWidth
        Next

        CellTopPos += DataGridView1.Rows(Row).Cells(0).Size.Height

        Row += 1
        If Row > DataGridView1.RowCount - 1 Then Exit For

    Next

    ' 
إذا لم تنتهي الأسطر أضف صفحة جديدة
    
If Row DataGridView1.RowCount Then e.HasMorePages True

End Sub 
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: