DataGrid.AllowNavigation Property
.NET Framework 4.5
Gets or sets a value indicating whether navigation is allowed.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Property Value
Type: System.Booleantrue if navigation is allowed; otherwise, false. The default is true.
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"); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.