DataGrid.AllowNavigationChanged 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在 AllowNavigation 属性更改后发生。
public:
event EventHandler ^ AllowNavigationChanged;
public event EventHandler AllowNavigationChanged;
member this.AllowNavigationChanged : EventHandler
Public Custom Event AllowNavigationChanged As EventHandler
事件类型
示例
下面的代码示例重置 属性 AllowNavigation 并引发 AllowNavigationChanged 事件。
private:
// Create an instance of the 'AllowNavigationChanged' EventHandler.
void CallAllowNavigationChanged()
{
myDataGrid->AllowNavigationChanged += gcnew EventHandler( this, &MyDataGrid::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 = String::Concat( myString, myBool ? (String^)" is " : " is not ", "allowed" );
// Show information about navigation.
MessageBox::Show( myString, "Navigation information" );
}
// 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 Sub CallAllowNavigationChanged()
AddHandler myDataGrid.AllowNavigationChanged, AddressOf Grid_AllowNavChange
End Sub
' Set the 'AllowNavigation' property on click of a button.
Private Sub myButton_Click(ByVal sender As Object, ByVal e As EventArgs)
If myDataGrid.AllowNavigation = True Then
myDataGrid.AllowNavigation = False
Else
myDataGrid.AllowNavigation = True
End If
End Sub
' Raise the event when 'AllowNavigation' property is changed.
Private Sub Grid_AllowNavChange(ByVal sender As Object, ByVal e As EventArgs)
Dim myString As String = "AllowNavigationChanged event raised, Navigation "
Dim myBool As Boolean = myDataGrid.AllowNavigation
' Create appropriate alert message.
myString = myString + IIF(mybool, "is", "is not") + "allowed"
' Show information about navigation.
MessageBox.Show(myString, "Navigation information")
End Sub
注解
如果 属性 AllowNavigation 设置为 false
,则不显示指向子表的链接。