AllowNavigation Property

DataGrid.AllowNavigation Property

 

Gets or sets a value indicating whether navigation is allowed.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool AllowNavigation { get; set; }

Property Value

Type: System.Boolean

true if navigation is allowed; otherwise, false. The default is true.

If this property is set to false, links to child tables are not shown.

The following code example toggles the AllowNavigation property between the true and false.

// 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
Available since 1.1
Return to top
Show:
© 2016 Microsoft