18-04-17, 12:53 PM
ارجو من الزملاء الكرام توضيح فكرة اضافة صفحة عند استخدام اداة 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
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