I have tried to print a datagrid content using the ff code. It only prints half the A4 page. Sometimes, the printed data list order is in reverse. What causes this? I want to print all content of a datagrid and it must print on multiple pages, if necessary. How should I modify this code in order to achieve that? Thanks for helping.
Code:
Private Sub OnDataGridPrinting(sender As Object, e As RoutedEventArgs)
Dim Printdlg As New System.Windows.Controls.PrintDialog()
If CBool(Printdlg.ShowDialog().GetValueOrDefault()) Then
Dim pageSize As New Size(Printdlg.PrintableAreaWidth, Printdlg.PrintableAreaHeight)
' sizing of the element.
dataGrid1.Measure(pageSize)
dataGrid1.Arrange(New Rect(5, 5, pageSize.Width, pageSize.Height))
Printdlg.PrintVisual(dataGrid1, Title)
End If
End Sub