tags:

views:

500

answers:

3

how to draw a circle and line in the picturebox? sorry for stupid question

thanx

A: 

The best way is to NOT draw a circle and line in a picturebox! It is not designed for that purpose. See these links for information about a picturebox and many other graphics (gdi) related inforamtion:

http://www.bobpowell.net/picturebox.htm

http://www.bobpowell.net

Chris Dunaway
A: 

the picturebox is a control and has an image as source - so you have to draw on the image and hand the image to the control to show it

MyImage = new Bitmap(fileToDisplay); pictureBox1.ClientSize = new Size(xSize, ySize); pictureBox1.Image = (Image) MyImage ;
Gambrinus
+1  A: 

or:

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawLine(
            new Pen(Color.Red,2f), 
            new Point(0,0), 
            new Point(pictureBox1.Size.Width, pictureBox1.Size.Height ));

        e.Graphics.DrawEllipse(
            new Pen(Color.Red, 2f),
            0,0, pictureBox1.Size.Width, pictureBox1.Size.Height  );
    }

Handle the paint event of the picture box and do your custom drawing there.

Paul Sasik