Control.Paintとは? わかりやすく解説

Control.Paint イベント

コントロールが再描画される発生します

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

Public Event Paint As PaintEventHandler
Dim instance As Control
Dim handler As PaintEventHandler

AddHandler instance.Paint, handler
public event PaintEventHandler Paint
public:
event PaintEventHandler^ Paint {
    void add (PaintEventHandler^ value);
    void remove (PaintEventHandler^ value);
}
/** @event */
public void add_Paint (PaintEventHandler value)

/** @event */
public void remove_Paint (PaintEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

フォーム上で PictureBox コントロール作成しPaint イベント使用して描画するコード例次に示します

' This example creates a PictureBox control on the form and draws to
 it. 
' This example assumes that the Form_Load event handler method is connected
 
' to the Load event of the form.
Private pictureBox1 As New
 PictureBox()

Private Sub Form1_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs) Handles MyBase.Load
    ' Dock the PictureBox to the form and set its background to white.
    pictureBox1.Dock = DockStyle.Fill
    pictureBox1.BackColor = Color.White
    ' Connect the Paint event of the PictureBox to the event handler
 method.
    AddHandler pictureBox1.Paint, AddressOf
 Me.pictureBox1_Paint

    ' Add the PictureBox control to the Form.
    Me.Controls.Add(pictureBox1)
End Sub 'Form1_Load


Private Sub pictureBox1_Paint(ByVal
 sender As Object, ByVal
 e As System.Windows.Forms.PaintEventArgs)
    ' Create a local version of the graphics object for the PictureBox.
    Dim g As Graphics = e.Graphics

    ' Draw a string on the PictureBox.
    g.DrawString("This is a diagonal line drawn on the control",
 _
        New Font("Arial", 10),
 Brushes.Red, New PointF(30.0F, 30.0F))
    ' Draw a line in the PictureBox.
    g.DrawLine(System.Drawing.Pens.Red, pictureBox1.Left, _ 
        pictureBox1.Top, pictureBox1.Right, pictureBox1.Bottom)
End Sub 'pictureBox1_Paint
// This example creates a PictureBox control on the form and draws to
 it.
// This example assumes that the Form_Load event handler method is
// connected to the Load event of the form.

private PictureBox pictureBox1 = new PictureBox();
private void Form1_Load(object sender, System.EventArgs
 e)
{
    // Dock the PictureBox to the form and set its background to white.
    pictureBox1.Dock = DockStyle.Fill;
    pictureBox1.BackColor = Color.White;
    // Connect the Paint event of the PictureBox to the event handler
 method.
    pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);

    // Add the PictureBox control to the Form.
    this.Controls.Add(pictureBox1);
}

private void pictureBox1_Paint(object sender,
 System.Windows.Forms.PaintEventArgs e)
{
    // Create a local version of the graphics object for the PictureBox.
    Graphics g = e.Graphics;

    // Draw a string on the PictureBox.
    g.DrawString("This is a diagonal line drawn on the control",
        new Font("Arial",10), System.Drawing.Brushes.Blue,
 new Point(30,30));
    // Draw a line in the PictureBox.
    g.DrawLine(System.Drawing.Pens.Red, pictureBox1.Left, pictureBox1.Top,
        pictureBox1.Right, pictureBox1.Bottom);
}
   // This example creates a PictureBox control on the form and draws to
 it.
   // This example assumes that the Form_Load event handler method is
   // connected to the Load event of the form.
private:
   PictureBox^ pictureBox1;
   void Form1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/
 )
   {
      pictureBox1 = gcnew PictureBox;

      // Dock the PictureBox to the form and set its background to white.
      pictureBox1->Dock = DockStyle::Fill;
      pictureBox1->BackColor = Color::White;

      // Connect the Paint event of the PictureBox to the event handler
 method.
      pictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler( this,
 &Form1::pictureBox1_Paint );

      // Add the PictureBox control to the Form.
      this->Controls->Add( pictureBox1 );
   }

   void pictureBox1_Paint( Object^ /*sender*/, System::Windows::Forms::PaintEventArgs^
 e )
   {
      // Create a local version of the graphics object for the PictureBox.
      Graphics^ g = e->Graphics;

      // Draw a string on the PictureBox.
      g->DrawString( "This is a diagonal line drawn on the control"
,
         gcnew System::Drawing::Font( "Arial",10 ), System::Drawing::Brushes::Blue,
 Point(30,30) );

      // Draw a line in the PictureBox.
      g->DrawLine( System::Drawing::Pens::Red, pictureBox1->Left, pictureBox1->Top
,
         pictureBox1->Right, pictureBox1->Bottom );
   }
// This example creates a PictureBox control on the form and draws to
 it.
// This example assumes that the Form_Load event handler method is
// connected to the Load event of the form.
private PictureBox pictureBox1 = new PictureBox();

private void Form1_Load(Object sender, System.EventArgs
 e)
{
    // Dock the PictureBox to the form and set its background to white.
    pictureBox1.set_Dock(DockStyle.Fill);
    pictureBox1.set_BackColor(Color.get_White());

    // Connect the Paint event of the PictureBox to the event handler
 
    // method.
    pictureBox1.add_Paint(new System.Windows.Forms.PaintEventHandler(this.
        pictureBox1_Paint));

    // Add the PictureBox control to the Form.
    this.get_Controls().Add(pictureBox1);
} //Form1_Load

private void pictureBox1_Paint(Object sender,
 
    System.Windows.Forms.PaintEventArgs e)
{
    // Create a local version of the graphics object for the PictureBox.
    Graphics g = e.get_Graphics();

    // Draw a string on the PictureBox.
    g.DrawString("This is a diagonal line drawn on the control", 
        new Font("Arial", 10), System.Drawing.Brushes.get_Blue(),
 
        (PointF)new PointF(30, 30));

    // Draw a line in the PictureBox.
    g.DrawLine(System.Drawing.Pens.get_Red(), pictureBox1.get_Left(), 
        pictureBox1.get_Top(), pictureBox1.get_Right(), 
        pictureBox1.get_Bottom());
} //pictureBox1_Paint
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ControlPaint クラス

共通の Windows コントロールとその要素描画するために使用するメソッド提供します。このクラス継承できません。

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

Public NotInheritable Class
 ControlPaint
public sealed class ControlPaint
public ref class ControlPaint sealed
public final class ControlPaint
public final class ControlPaint
解説解説
使用例使用例

ControlPaintコンストラクタ1 つ使用してフラットな Button コントロール描画するコード例次に示します

Imports System
Imports System.Drawing
Imports System.Windows.Forms

    Public Class Form1
        Inherits System.Windows.Forms.Form

        Private button1 As System.Windows.Forms.Button
 = New Button
        Private button2 As System.Windows.Forms.Button
 = New Button

        <System.STAThreadAttribute()>  _
        Public Shared Sub
 Main()
            System.Windows.Forms.Application.Run(New Form1)
        End Sub

        Public Sub New()
            Me.button2.Location = New Point(0,
 button1.Height + 10)
            AddHandler Me.button2.Click, AddressOf
 Me.button2_Click
            Me.Controls.Add(Me.button1)
            Me.Controls.Add(Me.button2)
        End Sub

        Private Sub button2_Click(sender As
 Object, e As System.EventArgs)
            ' Draws a flat button on button1.
            ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(button1.Handle),
 0, 0, button1.Width, button1.Height, ButtonState.Flat)
        End Sub 'button2_Click
End Class
using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
      private Button button1 = new Button();
      private Button button2 = new Button();


    [STAThread]
    static void Main() 
    {
        Application.Run(new Form1());
    }


    public Form1(){
        this.button2.Location = new Point(0,
 button1.Height + 10);
        this.Click += new EventHandler(this.button2_Click);
        this.Controls.Add(this.button1);
        this.Controls.Add(this.button2);
    }

    private void button2_Click(object sender,
 System.EventArgs e)
    {
        // Draws a flat button on button1.
        ControlPaint.DrawButton(
        System.Drawing.Graphics.FromHwnd(button1.Handle),0,0,button1.Width,button1.Height
,
                ButtonState.Flat);
    }
}
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public
 Form
{
private:
   Button^ button1;
   Button^ button2;

public:
   Form1()
   {
      button1 = gcnew Button;
      button2 = gcnew Button;
      this->button2->Location = Point(0,button1->Height
 + 10);
      this->Click += gcnew EventHandler( this,
 &Form1::button2_Click );
      this->Controls->Add( this->button1
 );
      this->Controls->Add( this->button2
 );
   }


private:

   void button2_Click( Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      
      // Draws a flat button on button1.
      ControlPaint::DrawButton( System::Drawing::Graphics::FromHwnd( button1->Handle
 ), 0, 0, button1->Width, button1->Height, ButtonState::Flat );
   }

};


[STAThread]
void main()
{
   Application::Run( gcnew Form1 );
}

import System.*;
import System.Drawing.*;
import System.Windows.Forms.*;

public class Form1 extends Form
{
    private Button button1 = new Button();
    private Button button2 = new Button();

    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        Application.Run(new Form1());
    } //main

    public Form1()
    {
        this.button2.set_Location(new Point(0,
 button1.get_Height() + 10));
        this.add_Click(new EventHandler(this.button2_Click));
        this.get_Controls().Add(this.button1);
        this.get_Controls().Add(this.button2);
    } //Form1

    private void button2_Click(Object sender,
 System.EventArgs e)
    {
        // Draws a flat button on button1.
        ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(
            button1.get_Handle()), 0, 0, button1.get_Width(), 
            button1.get_Height(), ButtonState.Flat);
    } //button2_Click
} //Form1
継承階層継承階層
System.Object
  System.Windows.Forms.ControlPaint
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ControlPaint プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ContrastControlDark ControlDark 色として使用する色を取得します
参照参照

関連項目

ControlPaint クラス
System.Windows.Forms 名前空間
Control クラス
ControlStyles

ControlPaint メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド CreateHBitmap16Bit 16 ビットカラー ビットマップ作成します
パブリック メソッド CreateHBitmapColorMask イメージから Win32 HBITMAP作成します
パブリック メソッド CreateHBitmapTransparencyMask 指定したビットマップの、透明として表示する色を示す色マスク作成します
パブリック メソッド Dark オーバーロードされますコントロール新しい濃い色のオブジェクト作成します
パブリック メソッド DarkDark 指定した色からコントロール新しい濃い色のオブジェクト作成します
パブリック メソッド DrawBorder オーバーロードされますボタン スタイルコントロール輪郭描画ます。
パブリック メソッド DrawBorder3D オーバーロードされますコントロール3 次元スタイル輪郭描画ます。
パブリック メソッド DrawButton オーバーロードされますボタン コントロール描画ます。
パブリック メソッド DrawCaptionButton オーバーロードされますキャプション ボタン コントロール描画ます。
パブリック メソッド DrawCheckBox オーバーロードされますチェック ボックス コントロール描画ます。
パブリック メソッド DrawComboButton オーバーロードされますコンボ ボックス コントロールのドロップダウン ボタン描画ます。
パブリック メソッド DrawContainerGrabHandle コンテナ コントロールグラブ ハンドル グリフを、指定したグラフィックス表面指定した範囲内描画ます。
パブリック メソッド DrawFocusRectangle オーバーロードされますフォーカスを示す四角形描画ます。
パブリック メソッド DrawGrabHandle 標準選択項目のグラブ ハンドル グリフを、指定した状態およびスタイルで、指定したグラフィックス表面指定した範囲内描画ます。
パブリック メソッド DrawGrid 1 ピクセル点線構成されグリッド指定した間隔で、指定した色を使用して指定したグラフィックス表面指定した範囲内描画ます。
パブリック メソッド DrawImageDisabled 指定したイメージ無効状態で描画ます。
パブリック メソッド DrawLockedFrame 画面表示されるロックされ選択項目のを、指定した範囲内指定したグラフィックス表面描画ます。主要な選択目色使用して描画するかどうか指定します
パブリック メソッド DrawMenuGlyph オーバーロードされますメニュー項目のコントロールメニュー グリフ描画ます。
パブリック メソッド DrawMixedCheckBox オーバーロードされます。 3 ステート チェック ボックス コントロール描画ます。
パブリック メソッド DrawRadioButton オーバーロードされますオプション ボタン コントロール描画ます。
パブリック メソッド DrawReversibleFrame 画面反転できるを、指定した範囲内に、指定した背景色使用して指定した状態で描画ます。
パブリック メソッド DrawReversibleLine 画面反転できる線を、指定した開始点と指定したエンド ポイントの間に、指定した背景色使用して描画ます。
パブリック メソッド DrawScrollButton オーバーロードされますスクロール バー コントロールスクロール ボタン描画ます。
パブリック メソッド DrawSelectionFrame 標準選択項目のを、指定した状態で、指定したグラフィックス表面に、指定した内部外部大きさで、指定した背景色使用して描画ます。
パブリック メソッド DrawSizeGrip オーバーロードされますフォームサイズ グリップ描画ます。
パブリック メソッド DrawStringDisabled オーバーロードされます指定した文字列無効状態で描画ます。
パブリック メソッド DrawVisualStyleBorder 無効状態の項目に、適切なスタイル文字列描画ます。
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド FillReversibleRectangle 画面上の塗りつぶされ反転できる四角形描画ます。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド Light オーバーロードされますコントロール新し明るい色のオブジェクト作成します
パブリック メソッド LightLight 指定した色からコントロール新し明るい色のオブジェクト作成します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ControlPaint クラス
System.Windows.Forms 名前空間
Control クラス
ControlStyles

ControlPaint メンバ

共通の Windows コントロールとその要素描画するために使用するメソッド提供します。このクラス継承できません。

ControlPaint データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ ContrastControlDark ControlDark 色として使用する色を取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド CreateHBitmap16Bit 16 ビットカラー ビットマップ作成します
パブリック メソッド CreateHBitmapColorMask イメージから Win32 HBITMAP作成します
パブリック メソッド CreateHBitmapTransparencyMask 指定したビットマップの、透明として表示する色を示す色マスク作成します
パブリック メソッド Dark オーバーロードされますコントロール新しい濃い色のオブジェクト作成します
パブリック メソッド DarkDark 指定した色からコントロール新しい濃い色のオブジェクト作成します
パブリック メソッド DrawBorder オーバーロードされますボタン スタイルコントロール輪郭描画ます。
パブリック メソッド DrawBorder3D オーバーロードされますコントロール3 次元スタイル輪郭描画ます。
パブリック メソッド DrawButton オーバーロードされますボタン コントロール描画ます。
パブリック メソッド DrawCaptionButton オーバーロードされますキャプション ボタン コントロール描画ます。
パブリック メソッド DrawCheckBox オーバーロードされますチェック ボックス コントロール描画ます。
パブリック メソッド DrawComboButton オーバーロードされますコンボ ボックス コントロールのドロップダウン ボタン描画ます。
パブリック メソッド DrawContainerGrabHandle コンテナ コントロールグラブ ハンドル グリフを、指定したグラフィックス表面指定した範囲内描画ます。
パブリック メソッド DrawFocusRectangle オーバーロードされますフォーカスを示す四角形描画ます。
パブリック メソッド DrawGrabHandle 標準選択項目のグラブ ハンドル グリフを、指定した状態およびスタイルで、指定したグラフィックス表面指定した範囲内描画ます。
パブリック メソッド DrawGrid 1 ピクセル点線構成されグリッド指定した間隔で、指定した色を使用して指定したグラフィックス表面指定した範囲内描画ます。
パブリック メソッド DrawImageDisabled 指定したイメージ無効状態で描画ます。
パブリック メソッド DrawLockedFrame 画面表示されるロックされ選択項目のを、指定した範囲内指定したグラフィックス表面描画ます。主要な選択目色使用して描画するかどうか指定します
パブリック メソッド DrawMenuGlyph オーバーロードされますメニュー項目のコントロールメニュー グリフ描画ます。
パブリック メソッド DrawMixedCheckBox オーバーロードされます。 3 ステート チェック ボックス コントロール描画ます。
パブリック メソッド DrawRadioButton オーバーロードされますオプション ボタン コントロール描画ます。
パブリック メソッド DrawReversibleFrame 画面反転できるを、指定した範囲内に、指定した背景色使用して指定した状態で描画ます。
パブリック メソッド DrawReversibleLine 画面反転できる線を、指定した開始点と指定したエンド ポイントの間に、指定した背景色使用して描画ます。
パブリック メソッド DrawScrollButton オーバーロードされますスクロール バー コントロールスクロール ボタン描画ます。
パブリック メソッド DrawSelectionFrame 標準選択項目のを、指定した状態で、指定したグラフィックス表面に、指定した内部外部大きさで、指定した背景色使用して描画ます。
パブリック メソッド DrawSizeGrip オーバーロードされますフォームサイズ グリップ描画ます。
パブリック メソッド DrawStringDisabled オーバーロードされます指定した文字列無効状態で描画ます。
パブリック メソッド DrawVisualStyleBorder 無効状態の項目に、適切なスタイル文字列描画ます。
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド FillReversibleRectangle 画面上の塗りつぶされ反転できる四角形描画ます。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド Light オーバーロードされますコントロール新し明るい色のオブジェクト作成します
パブリック メソッド LightLight 指定した色からコントロール新し明るい色のオブジェクト作成します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ControlPaint クラス
System.Windows.Forms 名前空間
Control クラス
ControlStyles


このページでは「.NET Framework クラス ライブラリ リファレンス」からControl.Paintを検索した結果を表示しています。
Weblioに収録されているすべての辞書からControl.Paintを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からControl.Paint を検索

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

辞書ショートカット

すべての辞書の索引

「Control.Paint」の関連用語

Control.Paintのお隣キーワード
検索ランキング

   

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



Control.Paintのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS