共用方式為


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 就會引發這個事件。

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於

另請參閱