Picturebox / PaintEvent

D

Dominik Klein

Hi,

I'm trying to draw on a picturebox, kinda like a very simple paint program.

I tried something like this:

Created a picturebox called pbDrawArea and added the derived event
handler for the paint event:

this.pbDrawArea.Paint += new
System.Windows.Forms.PaintEventHandler(this.pbDrawArea_Paint);

and then implement it and do my stuff:

private void pbDrawArea_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
foreach (Line line in this.lines)
{
g.DrawLine(new Pen(Color.Black), line.start.X,
line.start.Y, line.end.X, line.end.Y);
}
}

When compiling for PocketPC I get an "This method is not supported on
this platform".
However
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.paint.aspx
does something quite similar and the page clearly states the Paint event
for a picturebox object is supported under "Windows Mobile for Pocket PC"

Any mistakes in my code?
If the OnPaint event is not supported, what other way is there to
implement this?

Thanks,

Dominik
 
F

Fabien

Hi,

You can override teh OnPaint method :

protected override void OnPaint(PaintEventArgs pe)
{
// TODO: Add custom paint code here

// Create a Graphics object for the Control.
Graphics g = this.CreateGraphics();

.....

BR


Fabien Decret


ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/


Dominik Klein a écrit :
 

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