07-03-16, 06:00 PM
(آخر تعديل لهذه المشاركة : 07-03-16, 06:04 PM {2} بواسطة رومنس الشوق.)
لسلام عليكم ورحمه الله وبركاته
الكود ولكن مشكله الكود انه يطبع صفحه واحدة فقط عند وجود اكثر من صفحه لايطبع يخرج لك عداد يعد الارقام الى مالى نهايه ولا يطبع
وهذا هو الكود
المهم اولا ضيف في الفورم اداة PrintPreviewDialog1 و اداة PrintDocument1
ثم الكود هذا في زر الطباعة
والكود هنا PrintDocument1
نتيجة الكود عند ضغط زر الطباعة :
اتمني ان اجد حل لهذه المشكله لاني والله توقف المشروع بالكامل على هذه الخطوة
الكود ولكن مشكله الكود انه يطبع صفحه واحدة فقط عند وجود اكثر من صفحه لايطبع يخرج لك عداد يعد الارقام الى مالى نهايه ولا يطبع
وهذا هو الكود
المهم اولا ضيف في الفورم اداة PrintPreviewDialog1 و اداة PrintDocument1
ثم الكود هذا في زر الطباعة
كود :
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
والكود هنا PrintDocument1
كود :
Dim mRow As Integer = 0
Dim newpage As Boolean = True
With DataGridView1
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.LineAlignment = StringAlignment.Center
fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Single = 230
Do While mRow < .RowCount
Dim row As DataGridViewRow = .Rows(mRow)
Dim x As Single = 50
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)
Dim rrc As RectangleF = New RectangleF(x, 210, cell.Size.Width, cell.Size.Height)
e.Graphics.DrawRectangle(Pens.Black, rc.Left, rc.Top, rc.Width, rc.Height)
e.Graphics.DrawString(DataGridView1.Columns(cell.ColumnIndex).HeaderText, .Font, Brushes.Black, rrc, fmt)
e.Graphics.DrawString(DataGridView1.Rows(cell.RowIndex).Cells(cell.ColumnIndex).FormattedValue.ToString(), .Font, Brushes.Black, rc, fmt)
'من هنا رسم كتابات و تفاصيل اخرى في القائمة
Dim Font As New System.Drawing.Font("arial ", 12)
Dim Font1 As New System.Drawing.Font("arial ", 10)
'e.Graphics.DrawImage(logoPic.Image, <>, {})
e.Graphics.DrawImage(logoPic.Image, 353, 30, 170, 150)
e.Graphics.DrawString("قائمة صيانة شركة رويال الرحماني", Font, Brushes.Red, 343, 174)
e.Graphics.DrawString(TimeOfDay, Font, Brushes.Black, 50, 64)
e.Graphics.DrawString(DateString, Font, Brushes.Black, 50, 80)
e.Graphics.DrawString("شركة رويال الرحماني", Font, Brushes.Black, 653, 64)
e.Graphics.DrawString("الاجهزة الكهربائية", Font, Brushes.Black, 661, 84)
e.Graphics.DrawString("MM-DD-YYYY", Font1, Brushes.Black, 50, 99)
e.Graphics.DrawString("اربيل - شارع كوية - مقابل جامع ابراهيم كردي / بأدارة رائد الرحماني الوكيل الوحيد لشركة رويال الرحماني في كوردستان العراق", Font, Brushes.DarkBlue, 100, 1010)
e.Graphics.DrawString("هاتف الصيانة : 07828342083", Font, Brushes.DarkBlue, 350, 1035)
x += rc.Width
h = Math.Max(h, rc.Height)
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
نتيجة الكود عند ضغط زر الطباعة :
اتمني ان اجد حل لهذه المشكله لاني والله توقف المشروع بالكامل على هذه الخطوة