StatusBar.DrawItem 이벤트

정의

소유자가 그린 상태 표시줄 컨트롤의 시각적 측면이 변경될 때 발생합니다.Occurs when a visual aspect of an owner-drawn status bar control changes.

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 현재 날짜 및 사용자 지정 배경을 표시 합니다.The following code example demonstrates how to create an owner-drawn StatusBarPanel that displays a custom background and the current date. 이 예제에서는 연결 합니다 DrawItem 의 이벤트는 StatusBar 예제에 정의 된 이벤트 처리기에 제어 합니다.This example requires that you have connected the DrawItem event of a StatusBar control to the event handler defined in the example.

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 제어 합니다.You can use this event to perform drawing operations in an owner-drawn StatusBar control. 예를 들어 소유자가 그린 표시 하는 경우 StatusBarPanel 진행률 표시줄을 표시 하는,이 이벤트를 사용 하 여 패널에서 진행률 표시줄의 그리기를 수행 하 합니다.For example, if you display an owner-drawn StatusBarPanel that displays a progress bar, you can use this event to perform the drawing of the progress bar on the panel. 이벤트를 통해 제공 되는 데이터를 StatusBarDrawItemEventArgs 이벤트 처리기에 매개 변수로 전달 되는 개체를 사용 하면 그려야 하는 패널을 확인할 수 있습니다 및 Graphics 패널을 그리는 데 사용할 합니다.The data provided to the event through the StatusBarDrawItemEventArgs object passed as a parameter to the event handler enables you to determine the panel that needs to be drawn and the Graphics to use to draw to the panel. 이 이벤트는만 때 발생 합니다 StatusBarPanel.Style 의 속성을 StatusBarPanel 에서 StatusBar 로 설정 되어 OwnerDraw.This event is only raised when the StatusBarPanel.Style property of a StatusBarPanel in a StatusBar control is set to OwnerDraw.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.For more information about handling events, see Handling and Raising Events.

적용 대상

추가 정보