This documentation is archived and is not being maintained.

DataGrid.Navigate Event

Occurs when the user navigates to a new table.

[Visual Basic]
Public Event Navigate As NavigateEventHandler
[C#]
public event NavigateEventHandler Navigate;
[C++]
public: __event NavigateEventHandler* Navigate;

[JScript] In JScript, you can handle the events defined by a class, but you cannot define your own.

Event Data

The event handler receives an argument of type NavigateEventArgs containing data related to this event. The following NavigateEventArgs property provides information specific to this event.

Property Description
Forward Gets a value indicating whether to navigate in a forward direction.

Remarks

Use the Navigate event to reset individual column properties, such as Width, as appropriate to the table.

For more information about handling events, see Consuming Events.

Example

[Visual Basic] 
' Create an instance of the 'Navigate' NavigateEventHandler.
Private Sub CallNavigate()
   AddHandler myDataGrid.Navigate, AddressOf Grid_Navigate
End Sub 'CallNavigate


' Raise the event when navigating to another table.
Protected Sub Grid_Navigate(sender As Object, e As NavigateEventArgs)
   ' String variable used to show message.
   Dim myString As String = "Navigate event raised, moved to another table"
   ' Show the message when navigating to another table.
   MessageBox.Show(myString, "Table navigation information")
End Sub 'Grid_Navigate

[C#] 
// Instantiate the 'Navigate' NavigateEventHandler.
private void CallNavigate()
{
   myDataGrid.Navigate += new NavigateEventHandler(Grid_Navigate);
}

// Raise the event when navigating to another table.
protected void Grid_Navigate(object sender, NavigateEventArgs e)
{
   // String variable used to show message.
   string myString = "Navigate event raised, moved to another table";
   // Show the message when navigating to another table.
   MessageBox.Show(myString, "Table navigation information");
}

[C++] 
// Instantiate the 'Navigate' NavigateEventHandler.
private:
void CallNavigate() {
    myDataGrid->Navigate += 
        new NavigateEventHandler(this, &MyDataGrid::Grid_Navigate);
}

// Raise the event when navigating to another table.
protected:
void Grid_Navigate(Object* /*sender*/, NavigateEventArgs* /*e*/) {
    // String variable used to show message.
    String* myString = 
        S"Navigate event raised, moved to another table";
    // Show the message when navigating to another table.
    MessageBox::Show(myString, S"Table navigation information");
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DataGrid Class | DataGrid Members | System.Windows.Forms Namespace

Show: