ما فائدة الخاصية HasMorePages
هل فائدتها هي السماح بالعديد من الصفحات في الطباعة؟؟
////////////////////////////////////////////////////////////////////////////////////////////////////////
و إذا كان كذلك لماذا لا تتنفذ بالكود التالي
////////////////////////////////////////////////////////////////////////////////////////////////////////
Private printPageSettings As New PageSettings
Dim country() As String = {"Afghanistan", "Albania", "Australia", "Austria", "Bangladesh", "Barbados", "Belgium", "Bulgaria", "Burma", "Cambodia", "China", "Czechoslovakia", "Denmark", "Egypt", "Finland", "France", "Germany", "Greece", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Italy", "Japan", "Jordan", "Kuwait", "Laos", "Lebanon", "Luxemourg", "Malaysia", "Mongolia", "Nepal", "Netherlands", "New Zealand", "North Korea", "Norway", "Oman", "Pakistan", "Philippines", "Poland", "Portugal", "Romania", "Russia", "Saudi Arabia", "Singapore", "South Korea", "Spain", "Sri Lanka", "Sweden", "Switzerland", "Syria", "Taiwan", "Thiland", "Turkey", "United Kingdom", "Vietnam", "Yemen", "Yugoslavia"}
Dim capital() As String = {"Kabul", "Tirane", "Canberra", "Vienna", "Dacca", "Bridgetown", "Brussels", "Sofia", "Rangoon", "Phnom Penh", "Peking", "Prague", "Copenhangen", "Cairo", "Helsinki", "Paris", "Berlin", "Athens", "Budapest", "Reykjacik", "New Delhi", "Jakarta", "Tehran", "Baghdad", "Dublin", "Rome", "Tokya", "Amman", "Kuwait", "Vientiane", "Beirut", "Luxembourg", "Kuala Lumpur", "Ulaanbaatar", "Katmandu", "Amsterdam", "Wellington", "Pyongyang", "Oslo", "Muscat", "Islamabad", "Manila", "Warsaw", "Lisbon", "Bucharest", "Moscow", "Riyadh", "Singapore", "Seoul", "Madrid", "Colombo", "Stockholm", "Bern", "Damascus", "Taipei", "Bangkok", "Ankara", "London", "Hanoi", "Sana", "Belgrade"}
Private Sub ptnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ptnPrint.Click
Try
prtDoc.DefaultPageSettings = printPageSettings
Me.PrintDialog1.Document = prtDoc
If Me.PrintDialog1.ShowDialog = DialogResult.OK Then
prtDoc.Print()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
//--------------------------------------------------------------------------------
Private Sub prtDoc_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles prtDoc.PrintPage
Dim i, j, y As Integer
'Drow the string
For j = 1 To 3
e.Graphics.DrawString("Countries and Capitals - Page " & j, New Font("Arial", 20, FontStyle.Regular), Brushes.Black, (e.MarginBounds.Width) / 2 - 100, e.MarginBounds.Y + 10)
e.Graphics.DrawString("Country ", New Font("Arial", 14, FontStyle.Underline), Brushes.Black, e.MarginBounds.X + 40, e.MarginBounds.Y + 100)
e.Graphics.DrawString("Capital ", New Font("Arial", 14, FontStyle.Underline), Brushes.Black, e.MarginBounds.X + 350, e.MarginBounds.Y + 100)
y = e.MarginBounds.Y + 100
y += 20
If j = 1 Then
For i = 0 To 24
y += 20
e.Graphics.DrawString(country(i), New Font("Arial", 14, FontStyle.Regular), Brushes.Black, e.MarginBounds.X + 40, y)
e.Graphics.DrawString(capital(i), New Font("Arial", 14, FontStyle.Regular), Brushes.Black, e.MarginBounds.X + 350, y)
Next
End If
If j = 2 Then
For i = 25 To 49
y += 20
e.Graphics.DrawString(country(i), New Font("Arial", 14, FontStyle.Regular), Brushes.Black, e.MarginBounds.X + 40, y)
e.Graphics.DrawString(capital(i), New Font("Arial", 14, FontStyle.Regular), Brushes.Black, e.MarginBounds.X + 350, y)
Next
End If
If j = 3 Then
For i = 50 To 60
y += 20
e.Graphics.DrawString(country(i), New Font("Arial", 14, FontStyle.Regular), Brushes.Black, e.MarginBounds.X + 40, y)
e.Graphics.DrawString(capital(i), New Font("Arial", 14, FontStyle.Regular), Brushes.Black, e.MarginBounds.X + 350, y)
Next
End If
e.HasMorePages = True //here
Next
'Drow the picture
Dim h As Integer = e.MarginBounds.Height
h /= 2
e.Graphics.DrawImage(Me.PictureBox1.Image, e.MarginBounds.X, e.MarginBounds.Y, e.MarginBounds.Width, h)
e.HasMorePages = False
End Sub
//------------------------------------------------------------------------------
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
Try
prtDoc.DefaultPageSettings = printPageSettings
Me.PrintPreviewDialog1.Document = prtDoc
Me.PrintPreviewDialog1.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub