StatusBar.OnDrawItem メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > StatusBar.OnDrawItem メソッドの意味・解説 

StatusBar.OnDrawItem メソッド

OnDrawItem イベント発生させます

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Protected Overridable Sub
 OnDrawItem ( _
    sbdievent As StatusBarDrawItemEventArgs _
)
Dim sbdievent As StatusBarDrawItemEventArgs

Me.OnDrawItem(sbdievent)
protected virtual void OnDrawItem (
    StatusBarDrawItemEventArgs sbdievent
)
protected:
virtual void OnDrawItem (
    StatusBarDrawItemEventArgs^ sbdievent
)
protected void OnDrawItem (
    StatusBarDrawItemEventArgs sbdievent
)
protected function OnDrawItem (
    sbdievent : StatusBarDrawItemEventArgs
)

パラメータ

sbdievent

イベント データ格納している StatusBarDrawItemEventArgs。

解説解説
使用例使用例

カスタム背景現在の日付表示するオーナー描画 StatusBarPanel を作成する方法次のコード例示します。この例は、StatusBar コントロールの DrawItem イベントが、この例で定義されているイベント ハンドラ接続されていることを前提にしています。

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
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:
   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.set_Alignment(StringAlignment.Center);
    sf.set_LineAlignment(StringAlignment.Center);
    // Draw a back blackground in owner-drawn panel.
    sbdEvent.get_Graphics().FillRectangle(Brushes.get_Black(), 
        sbdEvent.get_Bounds());
    // Draw the current date (short date format) with white text 
    // in the control's font.
    sbdEvent.get_Graphics().DrawString(DateTime.get_Today().
        ToShortDateString(), statusBar1.get_Font(), Brushes.get_White(),
        RectangleF.op_Implicit(sbdEvent.get_Bounds()), sf);
} //DrawMyPanel
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

StatusBar.OnDrawItem メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



StatusBar.OnDrawItem メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS