about some easy drawing

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hi!

Nothing is being drawn when I run this piece of code ?
I can't see any wrong in the code but there must be some mistake in it.

private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen p = new Pen(Color.Red, 7);
p.DashStyle = DashStyle.Dot;
Bitmap bm = new Bitmap(400,400);
Graphics g = Graphics.FromImage(bm);
g.DrawPie(p,0,0,350,350,290,90);
}

//Tony
 
Tony Johansson said:
Nothing is being drawn when I run this piece of code ?
I can't see any wrong in the code but there must be some mistake in it.

private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen p = new Pen(Color.Red, 7);
p.DashStyle = DashStyle.Dot;
Bitmap bm = new Bitmap(400,400);
Graphics g = Graphics.FromImage(bm);
g.DrawPie(p,0,0,350,350,290,90);
}

You are drawing on a bitmap that you just created, and you never show
the bitmap. If you want the graphic to appear on screen, you should draw on
e.Graphics:

private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen p = new Pen(Color.Red, 7);
p.DashStyle = DashStyle.Dot;
Graphics g = e.Graphics;
g.DrawPie(p,0,0,350,350,290,90);
}
 
Back
Top