Prev: How do I set CAS permission for a single exe file
Next: .NET File/Folder Browser that is similar to the windows explorer
From: Tony Johansson on 22 May 2010 17:04 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
From: Alberto Poblacion on 22 May 2010 17:31
"Tony Johansson" <johansson.andersson(a)telia.com> wrote in message news:OxZriJf%23KHA.5464(a)TK2MSFTNGP05.phx.gbl... > 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); } |