Rectangle

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

I want to display a rectange on my pocket pc, but nothing
happens

I'm using the following code

System.Drawing.SolidBrush myBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);

System.Drawing.Graphics formGraphics = this.CreateGraphics
();

formGraphics.FillRectangle(myBrush, new Rectangle
(0,0,200,300));

myBrush.Dispose();

formGraphics.Dispose();


anything wron in my thinking?



thank you for help
 
Place the code in the OnPaint method of your form e.g.

protected override void OnPaint(PaintEventArgs e)

{

Graphics g = e.Graphics;

System.Drawing.SolidBrush myBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);

g.FillRectangle(myBrush, new Rectangle(0,0,200,300));

myBrush.Dispose();


base.OnPaint (e);

}



Peter
 
thanks


-----Original Message-----
Place the code in the OnPaint method of your form e.g.

protected override void OnPaint(PaintEventArgs e)

{

Graphics g = e.Graphics;

System.Drawing.SolidBrush myBrush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);

g.FillRectangle(myBrush, new Rectangle(0,0,200,300));

myBrush.Dispose();


base.OnPaint (e);

}



Peter


--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org




.
 
Peter's is the best method but if for some reason you need to do it some
place else or you want to update the screen more frequently than when
OnPaint gets called, you should be able to do it anywhere in the code (after
onload) as long as you override OnPaint and OnPaintBackground so that they
do not call the base functions. Otherwise they may draw over the top of
what you have drawn.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top