about some easy drawing

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
 
A

Alberto Poblacion

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);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top