

Private PictureBox pictureBox1 = new PictureBox() This example creates a PictureBox control on the form and draws to it. PictureBox1->Right, pictureBox1->Bottom ) G->DrawLine( System::Drawing::Pens::Red, pictureBox1->Left, pictureBox1->Top, Gcnew System::Drawing::Font( "Arial",10 ), System::Drawing::Brushes::Blue, Point(30,30) ) G->DrawString( "This is a diagonal line drawn on the control",

Create a local version of the graphics object for the PictureBox. Void pictureBox1_Paint( Object^ /*sender*/, System::Windows::Forms::PaintEventArgs^ e ) Add the PictureBox control to the Form. PictureBox1->Paint += gcnew System::Windows::Forms::PaintEventHandler( this, &Form1::pictureBox1_Paint ) Connect the Paint event of the PictureBox to the event handler method. Dock the PictureBox to the form and set its background to white. Void Form1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ ) connected to the Load event of the form. This example assumes that the Form_Load event handler method is

The following code example creates a PictureBox control on the form and uses the Paint event to draw to it. public:Įvent System::Windows::Forms::PaintEventHandler ^ Paint public event Paint public event ? Paint member this.Paint : Public Custom Event Paint As PaintEventHandler Event Type PaintEventHandler Examples
