Export (0) Print
Expand All

DataGrid.AllowNavigationChanged Event

Occurs when the AllowNavigation property has changed.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public event EventHandler AllowNavigationChanged
/** @event */
public void add_AllowNavigationChanged (EventHandler value)

/** @event */
public void remove_AllowNavigationChanged (EventHandler value)

JScript supports the use of events, but not the declaration of new ones.

If the AllowNavigation property is set to false, then no links to child tables are shown.

For more information about handling events, see Consuming Events.

The following code example resets the AllowNavigation property and raises the AllowNavigationChanged event.

// Create an instance of the 'AllowNavigationChanged' EventHandler.
private void CallAllowNavigationChanged()
{
   myDataGrid.AllowNavigationChanged += 
                                   new EventHandler(Grid_AllowNavChange);
}

// Set the 'AllowNavigation' property on click of a button.
private void myButton_Click(object sender, EventArgs e)
{
   if (myDataGrid.AllowNavigation == true)
      myDataGrid.AllowNavigation = false;
   else
      myDataGrid.AllowNavigation = true;
}

// Raise the event when 'AllowNavigation' property is changed.
private void Grid_AllowNavChange(object sender, EventArgs e)
{
   string myString = "AllowNavigationChanged event raised, Navigation ";
   bool myBool = myDataGrid.AllowNavigation;
   // Create appropriate alert message.
   myString = myString + (myBool ? " is " : " is not ") + "allowed";
   // Show information about navigation.
   MessageBox.Show(myString, "Navigation information");
}

// Create an instance of the 'AllowNavigationChanged' EventHandler.
private void CallAllowNavigationChanged()
{
    myDataGrid.add_AllowNavigationChanged(new EventHandler(
        GridAllowNavChange));
} //CallAllowNavigationChanged

// Set the 'AllowNavigation' property on click of a button.
protected void myButton_Click(Object sender, EventArgs e)
{
    if (myDataGrid.get_AllowNavigation() == true) {
        myDataGrid.set_AllowNavigation(false);
    }
    else {
        myDataGrid.set_AllowNavigation(true);
    }
} //myButton_Click

// Raise the event when 'AllowNavigation' property is changed.
protected void GridAllowNavChange(Object sender, EventArgs e)
{
    String myString = "AllowNavigationChanged event raised, Navigation ";
    boolean myBool = myDataGrid.get_AllowNavigation();

    // Create appropriate alert message.
    myString = myString + ((myBool) ? " is " : " is not " + "allowed");

    // Show information about navigation.
    MessageBox.Show(myString, "Navigation information");
} //GridAllowNavChange

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft