Note that there are some explanatory texts on larger screens.

plurals
  1. PODashed rectangles appear solid when expanding Winform window
    primarykey
    data
    text
    <p>I'm experiencing an issue with GDI+ while custom painting dashed rectangles. </p> <p>The vertical portion of dashed rectangles appear as solid, continuous lines when the window size is increased or when scrolling up/down. Moving the mouse faster results in fewer and fewer solid sections. Curiously the horizontal lines do not exhibit this behaviour and appear as expected. </p> <p>So far two non-optimal solutions have been to set <code>ResizeRedraw = true</code> or to call <code>Invalidate()</code> during <code>OnResize()</code> and <code>OnScroll()</code>. I'd of course like to avoid this as what I am really drawing is more complex and these slow calls destroy the fluid experience. I've also tried invalidating only the newly shown area to no avail - only a full Invalidate seems to work.</p> <p>Any pointers on how to work this out?</p> <p>Demo code:</p> <pre><code>using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; public class Form1 : Form { static void Main() { Application.Run(new Form1()); } public Form1() { this.ClientSize = new System.Drawing.Size(472, 349); DoubleBuffered = true; //ResizeRedraw = true; } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); int dimensions = 70; using ( Pen pen = new Pen(Color.Gray) ) { pen.DashStyle = DashStyle.Dash; for ( int x = 0; x &lt; 20; ++x ) { for ( int y = 0; y &lt; 20; ++y ) { Rectangle rect = new Rectangle(x * dimensions, y * dimensions, dimensions, dimensions); e.Graphics.DrawRectangle(pen, rect); } } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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