DataGrid.Navigate 事件

在用户浏览到新表时发生。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Event Navigate As NavigateEventHandler
用法
Dim instance As DataGrid
Dim handler As NavigateEventHandler

AddHandler instance.Navigate, handler
public event NavigateEventHandler Navigate
public:
event NavigateEventHandler^ Navigate {
    void add (NavigateEventHandler^ value);
    void remove (NavigateEventHandler^ value);
}
/** @event */
public void add_Navigate (NavigateEventHandler value)

/** @event */
public void remove_Navigate (NavigateEventHandler value)
JScript 支持使用事件,但不支持进行新的声明。

备注

使用 Navigate 事件将单个列属性(如 width)重置为适合该表的值。

有关处理事件的更多信息,请参见 使用事件

示例

' Create an instance of the 'Navigate' NavigateEventHandler.
Private Sub CallNavigate()
   AddHandler myDataGrid.Navigate, AddressOf Grid_Navigate
End Sub 'CallNavigate


' Raise the event when navigating to another table.
 Private Sub Grid_Navigate(ByVal sender As Object, ByVal e As NavigateEventArgs)
     ' String variable used to show message.
     Dim myString As String = "Navigate event raised, moved to another table"
     ' Show the message when navigating to another table.
     MessageBox.Show(myString, "Table navigation information")
 End Sub 'Grid_Navigate
// Instantiate the 'Navigate' NavigateEventHandler.
private void CallNavigate()
{
   myDataGrid.Navigate += new NavigateEventHandler(Grid_Navigate);
}

// Raise the event when navigating to another table.
private void Grid_Navigate(object sender, NavigateEventArgs e)
{
   // String variable used to show message.
   string myString = "Navigate event raised, moved to another table";
   // Show the message when navigating to another table.
   MessageBox.Show(myString, "Table navigation information");
}
   // Instantiate the 'Navigate' NavigateEventHandler.
private:
   void CallNavigate()
   {
      myDataGrid->Navigate += gcnew NavigateEventHandler( this, &MyDataGrid::Grid_Navigate );
   }

   // Raise the event when navigating to another table.
private:
   void Grid_Navigate( Object^ /*sender*/, NavigateEventArgs^ /*e*/ )
   {
      // String variable used to show message.
      String^ myString = "Navigate event raised, moved to another table";
      
      // Show the message when navigating to another table.
      MessageBox::Show( myString, "Table navigation information" );
   }
// Instantiate the 'Navigate' NavigateEventHandler.
private void CallNavigate()
{
    myDataGrid.add_Navigate(new NavigateEventHandler(GridNavigate));
} //CallNavigate

// Raise the event when navigating to another table.
protected void GridNavigate(Object sender, NavigateEventArgs e)
{
    // String variable used to show message.
    String myString = "Navigate event raised, moved to another table";

    // Show the message when navigating to another table.
    MessageBox.Show(myString, "Table navigation information");
} //GridNavigate

平台

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 命名空间