次の方法で共有


DataGrid.AllowNavigationChanged イベント

AllowNavigation プロパティが変更された場合に発生します。

Public Event AllowNavigationChanged As EventHandler
[C#]
public event EventHandler AllowNavigationChanged;
[C++]
public: __event EventHandler* AllowNavigationChanged;

[JScript] JScript では、このクラスで定義されているイベントを処理できます。ただし、独自に定義することはできません。

イベント データ

イベント ハンドラが EventArgs 型の引数を受け取りました。

解説

AllowNavigation プロパティが false に設定されている場合、子テーブルへのリンクは表示されません。イベント処理の詳細については、「 イベントの利用 」を参照してください。

使用例

[Visual Basic, C#, C++] AllowNavigation プロパティをリセットし、 AllowNavigationChanged イベントを発生させる例を次に示します。

 
' Create an instance of the 'AllowNavigationChanged' EventHandler.
Private Sub CallAllowNavigationChanged()
   AddHandler myDataGrid.AllowNavigationChanged, AddressOf Grid_AllowNavChange
End Sub 'CallAllowNavigationChanged


' Set the 'AllowNavigation' property on click of a button.
Protected Sub myButton_Click(sender As Object, e As EventArgs)
   If myDataGrid.AllowNavigation = True Then
      myDataGrid.AllowNavigation = False
   Else
      myDataGrid.AllowNavigation = True
   End If
End Sub 'myButton_Click
 
' Raise the event when 'AllowNavigation' property is changed.
Protected Sub Grid_AllowNavChange(sender As Object, 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 'Grid_AllowNavChange


[C#] 
// 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.
protected 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.
protected 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");
}

[C++] 
// Create an instance of the 'AllowNavigationChanged' EventHandler.
private:
void CallAllowNavigationChanged() {
    myDataGrid->AllowNavigationChanged += 
        new EventHandler(this, &MyDataGrid::Grid_AllowNavChange);
}

// Set the 'AllowNavigation' property on click of a button.
protected:
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.
void Grid_AllowNavChange(Object* /*sender*/, EventArgs* /*e*/) {
    String* myString = 
        S"AllowNavigationChanged event raised, Navigation ";
    bool myBool = myDataGrid->AllowNavigation;
    // Create appropriate alert message.
    myString = String::Concat(myString, 
        myBool ? S" is " : S" is not ", S"allowed");
    // Show information ab->Item[Out] navigation.

    MessageBox::Show(myString, S"Navigation information");
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataGrid クラス | DataGrid メンバ | System.Windows.Forms 名前空間