I want to draw a picture. This is the first time I set foot in this area (more used to SQL and co).
So I see 2, 3 stuff on the net ... But ... (yes there is always a but ...)
I use the following code:
Code:
public Form1()
{
InitializeComponent();
bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
//bmp2 = new Bitmap(pictureBox2.Width, pictureBox2.Height);
des = Graphics.FromImage(bmp);
des2 = pictureBox2.CreateGraphics();
}
private void button1_Click(object sender, EventArgs e)
{
//routine design
des.FillRectangle(new SolidBrush(Color.DarkCyan), new Rectangle(new Point(10, 10), new Size(50, 50)));
pictureBox1.Image = bmp;
}
private void button2_Click(object sender, EventArgs e)
{
//routine design
des2.FillRectangle(new SolidBrush(Color.DarkCyan), new Rectangle(new Point(10, 10), new Size(50, 50)));
//pictureBox2.Image = bmp2;
}
In the case of the picture box 1, I can not define the background as my PictureBox method replaces.
In the case of the picture box 2, I can define the background and graphic elements will come to position above. What I want!
But the problem is at a displacement of the window offscreen, or redirect, the Element graphic picture box 1 continues, then that element of the picture box 2 disappears ..
I grant you that it's probably a matter maternal 2nd year, but how to draw on my background without graphic element that disappears when handling the window?
Bookmarks