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

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

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");
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft