Share via


DataGrid.ParentRowsVisibleChanged 事件

ParentRowsVisible 属性值更改时发生。

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

语法

声明
Public Event ParentRowsVisibleChanged As EventHandler
用法
Dim instance As DataGrid
Dim handler As EventHandler

AddHandler instance.ParentRowsVisibleChanged, handler
public event EventHandler ParentRowsVisibleChanged
public:
event EventHandler^ ParentRowsVisibleChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public void add_ParentRowsVisibleChanged (EventHandler value)

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

备注

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

示例

Private Sub CallParentRowsVisibleChanged()
    AddHandler myDataGrid.ParentRowsVisibleChanged, AddressOf _
                                              DataGridParentRowsVisibleChanged_Clicked
End Sub 'CallParentRowsVisibleChanged


' Set the 'ParentRowsVisible' property on click of a button.
Private Sub ToggleVisible_Clicked(ByVal sender As Object, ByVal e As EventArgs)
    If myDataGrid.ParentRowsVisible = True Then
        myDataGrid.ParentRowsVisible = False
    Else
        myDataGrid.ParentRowsVisible = True
    End If
End Sub 'ToggleVisible_Clicked

' raise the event when 'ParentRowsVisible' property is changed.
Private Sub DataGridParentRowsVisibleChanged_Clicked(ByVal sender As Object, ByVal e As EventArgs)
    Dim myMessage As String = "ParentRowsVisibleChanged event raised, Parent row is : "
    Dim visible As Boolean = myDataGrid.ParentRowsVisible
    myMessage += IIF(visible, " ", "Not") + "Visible"
    MessageBox.Show(myMessage, "ParentRowsVisible information")
End Sub 'DataGridParentRowsVisibleChanged_Clicked
private void CallParentRowsVisibleChanged()
{
   myDataGrid.ParentRowsVisibleChanged +=
      new EventHandler(DataGridParentRowsVisibleChanged_Clicked);
}

// Set the 'ParentRowsVisible' property on click of a button.
private void ToggleVisible_Clicked(object sender, EventArgs e)
{
   if (myDataGrid.ParentRowsVisible == true)
      myDataGrid.ParentRowsVisible = false;
   else
      myDataGrid.ParentRowsVisible = true;
}

// raise the event when 'ParentRowsVisible' property is changed.
private void DataGridParentRowsVisibleChanged_Clicked(object sender, EventArgs e)
{
   string myMessage = "ParentRowsVisibleChanged event raised, Parent row is : ";
   bool visible = myDataGrid.ParentRowsVisible;
   myMessage += (visible ? " " : " NOT ") + "visible";

   MessageBox.Show(myMessage, "ParentRowsVisible information");
}
private:
   void CallParentRowsVisibleChanged()
   {
      myDataGrid->ParentRowsVisibleChanged += gcnew EventHandler( this, &MyForm::DataGridParentRowsVisibleChanged_Clicked );
   }

   // Set the 'ParentRowsVisible' property on click of a button.
   void ToggleVisible_Clicked( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( myDataGrid->ParentRowsVisible == true )
            myDataGrid->ParentRowsVisible = false;
      else
            myDataGrid->ParentRowsVisible = true;
   }

   // raise the event when 'ParentRowsVisible' property is changed.
   void DataGridParentRowsVisibleChanged_Clicked( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      String^ myMessage = "ParentRowsVisibleChanged event raised, Parent row is : ";
      bool visible = myDataGrid->ParentRowsVisible;
      myMessage = String::Concat( myMessage, visible ? (String^)" " : " NOT ", "visible" );
      MessageBox::Show( myMessage, "ParentRowsVisible information" );
   }
private void CallParentRowsVisibleChanged()
{
    myDataGrid.add_ParentRowsVisibleChanged(new 
        EventHandler(DataGridParentRowsVisibleChanged_Clicked));
} //CallParentRowsVisibleChanged

// Set the 'ParentRowsVisible' property on click of a button.
protected void ToggleVisible_Clicked(Object sender, EventArgs e)
{
    if (myDataGrid.get_ParentRowsVisible() == true) {
        myDataGrid.set_ParentRowsVisible(false);
    }
    else {
        myDataGrid.set_ParentRowsVisible(true);
    }
} //ToggleVisible_Clicked

// raise the event when 'ParentRowsVisible' property is changed.
protected void DataGridParentRowsVisibleChanged_Clicked(Object sender,
    EventArgs e) {
    String myMessage = "ParentRowsVisibleChanged event raised, "
        + "Parent row is : ";
    boolean visible = myDataGrid.get_ParentRowsVisible();
    myMessage +=(visible) ? " " : " NOT " + "visible";
    MessageBox.Show(myMessage, "ParentRowsVisible information");
} //DataGridParentRowsVisibleChanged_Clicked

平台

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