Note that there are some explanatory texts on larger screens.

plurals
  1. POdrawing over drawn graphics in winforms
    primarykey
    data
    text
    <p>hi I am trying to implement a form which resizes using coding. I have use the form_paint method to paint a border but I cannot "paint over" this border. What i am intending to do is that as i resize the form using a timer for a "smooth resizing", the form border would be updated along with the resize. what should i do?</p> <pre><code> Pen setupControlPen = new Pen(SystemColors.Control, 16); Pen setupDimGrayPen = new Pen(Color.DimGray, 5); </code></pre> <p>inside my form_paint: //draws a form border</p> <pre><code> Rectangle newRectangle; newRectangle = new Rectangle(new Point(0, 0), new Size(this.Width - 1, this.Height - 1)); setupGraphics.DrawRectangle(setupDimGrayPen, newRectangle); </code></pre> <p>inside a click event: //i tried to draw over the already drawn border.</p> <pre><code> Rectangle newRectangle = new Rectangle(new Point(0, 0), new Size(this.Width - 1, this.Height - 1)); setupGraphics.DrawRectangle(setupControlPen, newRectangle); </code></pre> <p>thank you!</p> <p>update: I tried using both resize_form event and timer to redraw but still cannot re-draw the border whenever i resize the form.</p> <p>update 2: the override method works! regarding the setupGraphics:</p> <pre><code> //global space Graphics setupGraphics; //form_load setupGraphics = this.CreateGraphics(); //so whenever I want to draw something during an event, supposing a button click event to draw a line: setupGraphics.DrawLine(pen, point1, point2); </code></pre> <p>I would like to ask are there any flaws in this method? or should everything be done inside the form_paint method?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload