VB6 PictureBox.line in c# - how?

dvanniel

New member
Joined
Nov 16, 2003
Messages
1
Location
Rotterdam, NL
Hi,

Just what i was looking for :D

But i have one question...how can i get the drawn item to stay on the form? After a minimize/restore the rectangle ive drawn disappears :confused:

This i what ive coded now:

public void button1_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
DrawTiles.Draw(g, 10.0F, 20.0F, new SolidBrush(Color.Black));
}


Where the Draw method is:


public static void Draw(Graphics g, float x, float y, SolidBrush brush)
{
g.FillRectangle (brush, x+1, y+1, 28.0F, 28.0F);
}


So when the user clicks on button1 then rectangle is drawn, but as i wrote before...the thing disappears after a min/rest.

Does anybody know how to handle this? :D
 
It disappears because you are only drawing it once. When the Paint event for the window occurs, for example min/max the window in your case, everything on the window is redrawn. Since you dont draw it again in the Paint event it will not be drawn again onto the form.

Please start a new thread next time instead of digging up old ones. :)
 
Last edited by a moderator:
Back
Top