title: C# Drawing rectangle
body: <p>I have create a ListView and get a data from a ListView to draw a rectangle.
  The ListView items count is always change with unknown count and also the x and y too. My ListView will be like this :</p>
  
  <pre><code>Subitem[0].Text || Subitem[1].text
  500                100
  100                200
  ++                 ++
  </code></pre>
  
  <p>By <code>Subitem[0] is X ,Subitem[1] is Y</code><br>
  And now I have create a code to draw the rectangle like this:</p>
  
  <pre><code>private void Draw_Tick(object sender, EventArgs e)
  {
     this.Invalidate();
     Pen p = new Pen(Color.Red);
     SolidBrush sb = new SolidBrush(Color.Red);
     Graphics g = PaintingPanel.CreateGraphics();
     for (int i = 0; i &lt; ListView1.Items.Count + 1; i++)
        {
           p.Width = 3;
           g.SmoothingMode = SmoothingMode.HighSpeed;
           g.InterpolationMode = InterpolationMode.Low;
           g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
  
           Rectangle rectf = new Rectangle(X.Split(',')[i],Y.Split(',')[i], 50, 75);
           g.DrawRectangle(p,rectf);     
        }
  }
  </code></pre>
  
  <p>Add the X and Y to Array</p>
  
  <pre><code>Public static string X;
  Public static string Y;
  
  for (int i = 0; i &lt; ListView1.Items.Count + 1; i++)
              {
                  List&lt;string&gt; ls = new List&lt;string&gt;();
  
  
                  foreach (ListViewItem item in ListView1.Items)
                  {
                      ls.Add(item.SubItems[0].Text);
  
                  }
                  X = string.Join(",", ls);
              }
  
  
  for (int i = 0; i &lt; ListView1.Items.Count + 1; i++)
              {
                  List&lt;string&gt; ls2 = new List&lt;string&gt;();
  
  
                  foreach (ListViewItem item in ListView1.Items)
                  {
                      ls2.Add(item.SubItems[1].Text);
  
                  }
                  Y = string.Join(",", ls2);
              }
  </code></pre>
  
  <p>But my point is I have used <code>this.Invalidate()</code> to clear the drawing and create a new drawing because the data changed. My question is how can I just move the rectangle instead of using <code>this.invalidate</code> to clear the drawing (Because its kind of flashing when <code>this.Invalidate();</code>.</p>