Most of the time we want to work with the grid, e.g., adding, editing, processing and even exporting, but when we loop to the grid using For Each we are bounded only to the current page. To solve the problem you need to set the PageSize to zero of the Property collection of the grid then set it back again to its original PageSize. Below is the example code:
Private Sub exportClicked(sender As Object, e As System.Windows.RoutedEventArgs) Dim PageSize As Integer Dim dialog = New SaveFileDialog() PageSize = Me.Details.Properties.Table1Items.PageSize Me.Details.Properties.Table1Items.PageSize = 0 dialog.Filter = "CSV (*.csv)|*.csv" If dialog.ShowDialog() = True Then Dim csv As String = GetTextCSV() Using stream As New StreamWriter(dialog.OpenFile()) stream.Write(csv) stream.Close() End Using End If Me.Details.Properties.Table1Items.PageSize = PageSize End Sub
Notice that before I tried to export the data in my grid to a CSV file I set the PageSize to zero. But that is not the only important thing here, notice that we use the Me.Details.Properties collection. I believe this collection holds many answers to some screen problems.
If you find this blog helpful, you can make the donation by clicking the Paypal button below.