Control.VisibleChanged 事件

定义

Visible 属性值更改时发生。

public:
 event EventHandler ^ VisibleChanged;
public event EventHandler VisibleChanged;
public event EventHandler? VisibleChanged;
member this.VisibleChanged : EventHandler 
Public Custom Event VisibleChanged As EventHandler 

事件类型

示例

下面的代码示例在VisibleChanged控件的Label属性值发生更改时Visible引发 事件。

private:
   void Button_HideLabel( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      myLabel->Visible = false;
   }

   void AddVisibleChangedEventHandler()
   {
      myLabel->VisibleChanged += gcnew EventHandler( this, &MyForm::Label_VisibleChanged );
   }

   void Label_VisibleChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      MessageBox::Show( "Visible change event raised!!!" );
   }
private void Button_HideLabel(object sender, EventArgs e)
{
   myLabel.Visible = false;
}

private void AddVisibleChangedEventHandler()
{
   myLabel.VisibleChanged += new EventHandler(this.Label_VisibleChanged);
}

private void Label_VisibleChanged(object sender, EventArgs e)
{
   MessageBox.Show("Visible change event raised!!!");
}
Private Sub Button_HideLabel(ByVal sender As Object, ByVal e As EventArgs)
   myLabel.Visible = False
End Sub


Private Sub AddVisibleChangedEventHandler()
   AddHandler myLabel.VisibleChanged, AddressOf Label_VisibleChanged
End Sub


Private Sub Label_VisibleChanged(ByVal sender As Object, ByVal e As EventArgs)
   MessageBox.Show("Visible change event raised!!!")
End Sub

注解

如果 Visible 属性通过编程修改或用户交互进行更改,则会引发此事件。

有关处理事件的详细信息,请参阅 处理和引发事件

适用于

另请参阅