You could grab the image, manipulate it using GDI+, and set the Image property to the new image.
Bob
Main Topics
Browse All TopicsHi guys 'n gals,
How would I go about creating a PictureBox (100 x 100), which has a white background and a red line, going at a 45 degree angle from the bottom left to the upper right of the PictureBox? I know this most likely requires the DrawLine() function, but I have no idea to how make that save the line as part of the PictureBox's Image.
Any thoughts?
Cheers!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The following will draw the line on an image that is assigned to the picturebox. You can omit the code that dynamically creates the PictureBox if you already have it added to the page.
-----------------------
Bitmap img = new Bitmap(100, 100);
System.Drawing.Graphics g = Graphics.FromImage(img);
Pen drawingPen = new Pen(Color.Red, 1);
g.DrawLine(drawingPen, 0, 100, 100, 0);
PictureBox pbox = new PictureBox();
pbox.Top = 10;
pbox.Left = 10;
pbox.Width = 100;
pbox.Height = 100;
pbox.BackColor = Color.White;
pbox.Image = img;
this.Controls.Add(pbox);
Business Accounts
Answer for Membership
by: CBeach1980Posted on 2007-04-11 at 14:53:00ID: 18893786
Drawing on top of a picturebox will not cause it to keep the line. If the picturebox refreshes you will lose the added line. You can draw on the image itself and then assign it to the picturebox though.