Click here to Skip to main content
11,802,389 members (29,641 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Visual-Studio VS2010
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 12: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
0 OriginalGriff 475
1 KrunalRohit 366
2 F-ES Sitecore 295
3 Afzaal Ahmad Zeeshan 230
4 CHill60 220
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,645
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 30 Oct 2012
Copyright © CodeProject, 1999-2015
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