StatusBar.DrawItem 이벤트

정의

소유자가 그린 상태 표시줄 컨트롤의 시각적 측면이 변경될 때 발생합니다.

public:
 event System::Windows::Forms::StatusBarDrawItemEventHandler ^ DrawItem;
public event System.Windows.Forms.StatusBarDrawItemEventHandler DrawItem;
member this.DrawItem : System.Windows.Forms.StatusBarDrawItemEventHandler 
Public Custom Event DrawItem As StatusBarDrawItemEventHandler 

이벤트 유형

예제

다음 코드 예제에서는 사용자 지정 배경 및 현재 날짜를 표시 하는 소유자 그리기를 StatusBarPanel 만드는 방법을 보여 줍니다. 이 예제에서는 컨트롤의 DrawItemStatusBar 이벤트를 예제에 정의된 이벤트 처리기에 연결해야 합니다.

private:
   void DrawMyPanel( Object^ /*sender*/, System::Windows::Forms::StatusBarDrawItemEventArgs^ sbdevent )
   {
      // Create a StringFormat object to align text in the panel.
      StringFormat^ sf = gcnew StringFormat;

      // Format the String of the StatusBarPanel to be centered.
      sf->Alignment = StringAlignment::Center;
      sf->LineAlignment = StringAlignment::Center;

      // Draw a back blackground in owner-drawn panel.
      sbdevent->Graphics->FillRectangle( Brushes::Black, sbdevent->Bounds );

      // Draw the current date (short date format) with white text in the control's font.
      sbdevent->Graphics->DrawString( DateTime::Today.ToShortDateString(), statusBar1->Font, Brushes::White, sbdevent->Bounds, sf );
   }
private void DrawMyPanel(object sender, System.Windows.Forms.StatusBarDrawItemEventArgs sbdevent)
{
   // Create a StringFormat object to align text in the panel.
   StringFormat sf = new StringFormat();
   // Format the String of the StatusBarPanel to be centered.
   sf.Alignment = StringAlignment.Center;
   sf.LineAlignment = StringAlignment.Center;

   // Draw a black background in owner-drawn panel.
   sbdevent.Graphics.FillRectangle(Brushes.Black, sbdevent.Bounds);
   // Draw the current date (short date format) with white text in the control's font.
   sbdevent.Graphics.DrawString(DateTime.Today.ToShortDateString(), 
      statusBar1.Font,Brushes.White,sbdevent.Bounds,sf);
}
Private Sub StatusBar1_DrawItem(ByVal sender As Object, ByVal sbdevent As System.Windows.Forms.StatusBarDrawItemEventArgs) Handles StatusBar1.DrawItem

   ' Create a StringFormat object to align text in the panel.
   Dim sf As New StringFormat()
   ' Format the String of the StatusBarPanel to be centered.
   sf.Alignment = StringAlignment.Center
   sf.LineAlignment = StringAlignment.Center

   ' Draw a black background in owner-drawn panel.
   sbdevent.Graphics.FillRectangle(Brushes.Black, sbdevent.Bounds)
   ' Draw the current date (short date format) with white text in the control's font.
   sbdevent.Graphics.DrawString(DateTime.Today.ToShortDateString(), StatusBar1.Font, Brushes.White, _
         New RectangleF(sbdevent.Bounds.X, sbdevent.Bounds.Y, _
         sbdevent.Bounds.Width, sbdevent.Bounds.Height), sf)
End Sub

설명

이 이벤트를 사용 하 여 소유자가 그린에서 그리기 작업을 수행할 StatusBar 제어 합니다. 예를 들어 진행률 표시줄을 표시하는 소유자 그리기를 StatusBarPanel 표시하는 경우 이 이벤트를 사용하여 패널에서 진행률 표시줄 그리기를 수행할 수 있습니다. 이벤트 처리기에 매개 변수로 전달된 개체를 통해 StatusBarDrawItemEventArgs 이벤트에 제공된 데이터를 사용하면 그려야 하는 패널과 Graphics 패널에 그리는 데 사용할 을 결정할 수 있습니다. 이 이벤트는 컨트롤의 StatusBarPanelStatusBar 의 속성이 StatusBarPanel.Style 로 설정된 경우에만 발생합니다OwnerDraw.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

적용 대상

추가 정보