Version

PageIndexChanging Event

Event raised prior to a new page index being assigned.
Syntax
'Declaration
 
Public Event PageIndexChanging As EventHandler(Of CancellablePageChangingEventArgs)
public event EventHandler<CancellablePageChangingEventArgs> PageIndexChanging
Event Data

The event handler receives an argument of type CancellablePageChangingEventArgs containing data related to this event. The following CancellablePageChangingEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from Infragistics.CancellableEventArgs) 
ColumnLayout The ColumnLayout that this event was triggered for.
Level The depth at which the ColumnLayout is representing.
NextPageIndex The PageIndex of the page of data that will become visible.
Rows Gets the collection of rows or row island that this particular ColumnLayout will represent.
Example
This sample demonstrates how to handle the PageIndexChanging event which is fired right before the page index is changed.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

AddHandler Me.MyGrid.PageIndexChanging, AddressOf MyGrid_PageIndexChanging

Private Sub MyGrid_PageIndexChanging(ByVal sender As Object, ByVal e As CancellablePageChangingEventArgs)
   Dim nextPage As Integer = e.NextPageIndex
   System.Diagnostics.Debug.WriteLine("Next Page Index: " + nextPage.ToString() + ". You can only view odd numbered pages")

   'Since the page index is zero based,this will get the odd number page
   If nextPage Mod 2 = 0 Then
      'cancel the event so that only odd numbered pages can be viewed
      e.Cancel = True
   End If
End Sub 'MyGrid_PageIndexChanging
this.MyGrid.PageIndexChanging += new EventHandler<CancellablePageChangingEventArgs>(dataGrid_PageIndexChanging);

private void MyGrid_PageIndexChanging(object sender, CancellablePageChangingEventArgs e)
{
   int nextPage = e.NextPageIndex;
   
   //Display to the scroll viewer
   System.Diagnostics.Debug.WriteLine("Next Page Index: " + nextPage + ". You can only 
    view odd numbered pages") ;

   // Since the page index is zero based,this will get the odd number page
   if ((nextPage % 2) == 0)
   {
      // Cancel the event so that only odd numbered pages can be viewed
      e.Cancel = true;
   }
}
<ig:XamGrid x:Name="MyGrid" 
   
PageIndexChanging="MyGrid_PageIndexChanging">
</ig:XamGrid>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also