Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 i've drawn disappears :confused:

 

This i what i've 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

  • *Experts*
Posted (edited)

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 don't 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. :)

Edited by mutant

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...