Control.OnParentFontChanged(EventArgs) 메서드

정의

컨트롤 컨테이너의 FontChanged 속성 값이 변경되면 Font 이벤트를 발생시킵니다.

protected:
 virtual void OnParentFontChanged(EventArgs ^ e);
protected virtual void OnParentFontChanged (EventArgs e);
abstract member OnParentFontChanged : EventArgs -> unit
override this.OnParentFontChanged : EventArgs -> unit
Protected Overridable Sub OnParentFontChanged (e As EventArgs)

매개 변수

e
EventArgs

이벤트 데이터가 포함된 EventArgs입니다.

예제

다음 코드 예제는 속성 값이 변경될 때 Text 실행되는 이벤트 발생 메서드입니다. Control 클래스에는 PropertyName 값이 변경되면 해당 PropertyNameChanged 이벤트를 발생시키는 Name pattern OnPropertyNameChanged이 있는 여러 메서드가 있습니다(PropertyName은 해당 속성의 이름을 나타남).

다음 코드 예제에서는 통화 데이터를 표시하는 파생 클래스의 TextBox 를 변경 ForeColor 합니다. 이 예제에서는 텍스트를 10진수로 변환하고 을 으로 Color.Red 변경하고, 숫자가 음수이면 를 로 변경 ForeColor 합니다Color.Black. 이 예제에서는 클래스에서 파생되는 클래스가 TextBox 있어야 합니다.

protected:
   virtual void OnTextChanged( System::EventArgs^ e ) override
   {
      try
      {
         // Convert the text to a Double and determine
         // if it is a negative number.
         if ( Double::Parse( this->Text ) < 0 )
         {
            // If the number is negative, display it in Red.
            this->ForeColor = Color::Red;
         }
         else
         {
            // If the number is not negative, display it in Black.
            this->ForeColor = Color::Black;
         }
      }
      catch ( Exception^ ) 
      {
         // If there is an error, display the
         // text using the system colors.
         this->ForeColor = SystemColors::ControlText;
      }

      TextBox::OnTextChanged( e );
   }
protected override void OnTextChanged(System.EventArgs e)
{
   try
   {
      // Convert the text to a Double and determine
      // if it is a negative number.
      if(double.Parse(this.Text) < 0)
      {
         // If the number is negative, display it in Red.
         this.ForeColor = Color.Red;
      }
      else
      {
         // If the number is not negative, display it in Black.
         this.ForeColor = Color.Black;
      }
   }
   catch
   {
      // If there is an error, display the 
      // text using the system colors.
      this.ForeColor = SystemColors.ControlText;
   }
   
   base.OnTextChanged(e);
}
Protected Overrides Sub OnTextChanged(e As System.EventArgs)
   Try
      ' Convert the text to a Double and determine
      ' if it is a negative number.
      If Double.Parse(Me.Text) < 0 Then
         ' If the number is negative, display it in Red.
         Me.ForeColor = Color.Red
      Else
         ' If the number is not negative, display it in Black.
         Me.ForeColor = Color.Black
      End If
   Catch
      ' If there is an error, display the
      ' text using the system colors.
      Me.ForeColor = SystemColors.ControlText
   End Try

   MyBase.OnTextChanged(e)
End Sub

설명

이벤트가 발생하면 대리자를 통해 이벤트 처리기가 호출됩니다. 자세한 내용은 이벤트 처리 및 발생합니다.

OnParentFontChanged 메서드는 파생된 클래스가 대리자를 연결 하지 않고 이벤트를 처리할 수 있습니다. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.

상속자 참고

파생 클래스에서 OnParentFontChanged(EventArgs)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnParentFontChanged(EventArgs) 메서드를 호출해야 합니다.

적용 대상

추가 정보