Control.VisibleChanged Control.VisibleChanged Control.VisibleChanged Control.VisibleChanged Event

定義

發生在 Visible 屬性值變更時。Occurs when the Visible property value changes.

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

範例

下列程式碼範例會在VisibleChanged Label控制項的Visible屬性值變更時引發事件。The following code example raises the VisibleChanged event when the Visible property value of the Label control has changed.

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 'Button_HideLabel


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


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

備註

如果以程式設計方式修改Visible或使用者互動來變更屬性, 就會引發這個事件。This event is raised if the Visible property is changed by either a programmatic modification or user interaction.

如需處理事件的詳細資訊, 請參閱處理和引發事件For more information about handling events, see Handling and Raising Events.

適用於

另請參閱