Is it possible to draw on top of a picture box Here's my code so far:
Pen blackPen = new Pen(Color.Black, 3); // Create rectangle for ellipse. Rectangle rect = new Rectangle(0, 0, 200, 100); // Draw ellipse to screen.e.Graphics.DrawEllipse(blackPen, rect);
but it prints behind the controls on my form. Is there some way to 'send to back' everything except my ellipse
Please help
Peter

Draw on top of picturebox?
Mark Hollman
I'd like to now make the ellipse semi transparent, but the this doesn't seem to work:
e.Graphics.FillEllipse(new SolidBrush(Color.FromArgb(50,255,255,255)),rect);
any thoughts why
Thanks,
Pete
JDFox
Kody Clemens
Can you give me an example I'm not exactly sure what you mean.
Thank you sir,
Pete M
amanzoor
Phil_Ramos
Assuming that you're using CF 2.0, the Paint event on the PictureBox has apparently been marked as not supported. This is surprising as, from memory, painting on a PictureBox was something that came up frequently in the newsgroups with CF 1.0. Anyways, you can hook the Paint event manually, even though it is not shown in the Properties window at design-time or Intellisense in the editor. You will get a warning that this is not supported; however, I just tested this on Windows Mobile 5.0 PPC and it worked as expected.
...
public Form1()
{
InitializeComponent();
this.pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);
}
void pictureBox1_Paint(object sender, PaintEventArgs e)
{
using (Pen p = new Pen(Color.Black, 3))
{
e.Graphics.DrawEllipse(p, 0, 0, this.pictureBox1.Width, this.pictureBox1.Height);
}
}
...
The other option is to create a new control, that inherits from the PictureBox control or some other control such as Control, override the OnPaint method, and perform any custom painting in this method.
Bahman; Fakhr
This question has been answered here...
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=282033&SiteID=1&mode=1
Yeowser
you also can code the class yourself inherits with control, inside the class use the OnMouseDown, OnMouseMove and OnMouseUp methods.
shiggsy
rokana3
djMP2006
My image is larger than the viewable screen on the ppc, so vertical and horizontal scrollbars automatically appear. Do you know of a scroll function in C# for these types of scrollbars Is there a way to scroll to a certain point
Thanks in advance.
peter
Steven Raybell
I am trying to update the location of the ellipse on a timer tick.
Here's my Paint method:
void pictureBox1_Paint (object sender, PaintEventArgs e)
{
using (Pen p = new Pen(Color.Gray,2))
{
Rectangle rect - new Rectangle(posX, posY, 10,10);
e.Graphics.DrawEllipse(p, rect);
e.Graphics.FillEllipse(new SolidBrush(Color.Yellow), rect);
}
}
Would it be possible remove the ellipse i just drew and then, then draw it to a new location
Oh, and what is the syntax for calling this routine from a timer_tick method
Thanks for all of your help by the way!
Pete M