Charu

Charu

  • NA
  • 128
  • 7.8k

how to move multiple or list rectangles drawn image?

May 16 2017 3:34 AM

I want to move my newly drawn rectangles from x direction to X++ , or y to Y++ , and while moving by button event , old rectangle should be deleted and new one should appear . 

 
{ // listRec has 9 rectangles and this is button click event . Rectangle[] recn = listRec.ToArray(); for (int i = 0; i < 9; i++) { Rectangle newrec = new System.Drawing.Rectangle();              newrec.X = recn[i].X + j;             newrec.Y = recn[i].Y;             newrec.Width = recn[i].Width;             newrec.Height = recn[i].Height; Rectangle rect = new Rectangle(newrec.X, newrec.Y,newrec.Width, newrec.Height));                     g.DrawRectangle(Pens.Red, rect);              pictureBox1.Refresh(); //ra[0].Location.X = newrec(ra[0].X+10,ra[0].Y,ra[0].Width,ra[0].Height); }         pictureBox1.Invalidate(); this.Invalidate();           j = j + 10;         pictureBox1.Refresh(); }

Answers (1)