Click here to Skip to main content
13,259,194 members (50,963 online)
Rate this:
Please Sign up or sign in to vote.
1)I created a figure in a picturebox , and now all of these figures, I want to draw inside the figure, is that possible?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test_Draw
    public partial class Form1 : Form
        public Form1()
        private void Form1_Load(object sender, EventArgs e)
        private void Form1_Paint(object sender, PaintEventArgs e)
            e.Graphics.FillPie(Brushes.Azure, 0 - 450, 0, 1000, 1000, 270, 90); 
            e.Graphics.DrawLine(Pens.Blue, 0, 500, 500, 400);
            Font f = new Font("Arial", 20);
            e.Graphics.DrawString("We learn to draw!", f, Brushes.Black, 200, 200);
Posted 30-Oct-12 13:26pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It is possible but makes no sense, whatsoever. It's much better to draw immediately on some control without any images in it. The PictureBox control is only useful for very simple way of adding already existing images (bitmaps). If you need something dynamic (interactive, animated, anything), this middleman image does not help at all, only forces you in doing unnecessary job and waste extra resources. You need to draw on a "regular" control (a custom one derived from System.Windows.Forms.Control, on Panel or something like that).

I'll explain what to do. Please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

And, for some more detail:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 30 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100