How to remove programmatically the paging in the grid of Microsoft Ligthswitch?

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())
                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.


Software developer living in the Philippines.

Posted in Lightswitch
2 comments on “How to remove programmatically the paging in the grid of Microsoft Ligthswitch?
  1. Great ! An alternative could be a for loop over the pages. The advantage is that by doing so , you can handle large amonunts of data. When you set the page size to 0, and you have let’s say 100.000 records you risk ending up with the request-response timeout

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn


Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: