다음을 통해 공유


DataGrid.AllowNavigation 속성

탐색이 허용되는지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Property AllowNavigation As Boolean
‘사용 방법
Dim instance As DataGrid
Dim value As Boolean

value = instance.AllowNavigation

instance.AllowNavigation = value
public bool AllowNavigation { get; set; }
public:
property bool AllowNavigation {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AllowNavigation ()

/** @property */
public void set_AllowNavigation (boolean value)
public function get AllowNavigation () : boolean

public function set AllowNavigation (value : boolean)

속성 값

탐색이 허용되면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

설명

이 속성이 false로 설정되면 자식 테이블에 대한 링크가 표시되지 않습니다.

예제

다음 코드 예제에서는 AllowNavigation 속성을 truefalse 사이에서 전환합니다.

' 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.
 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 'myButton_Click
 
' 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 'Grid_AllowNavChange
// 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");
}
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.add_AllowNavigationChanged(new EventHandler(
        GridAllowNavChange));
} //CallAllowNavigationChanged

// Set the 'AllowNavigation' property on click of a button.
protected void myButton_Click(Object sender, EventArgs e)
{
    if (myDataGrid.get_AllowNavigation() == true) {
        myDataGrid.set_AllowNavigation(false);
    }
    else {
        myDataGrid.set_AllowNavigation(true);
    }
} //myButton_Click

// Raise the event when 'AllowNavigation' property is changed.
protected void GridAllowNavChange(Object sender, EventArgs e)
{
    String myString = "AllowNavigationChanged event raised, Navigation ";
    boolean myBool = myDataGrid.get_AllowNavigation();

    // Create appropriate alert message.
    myString = myString + ((myBool) ? " is " : " is not " + "allowed");

    // Show information about navigation.
    MessageBox.Show(myString, "Navigation information");
} //GridAllowNavChange

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

DataGrid 클래스
DataGrid 멤버
System.Windows.Forms 네임스페이스