Questo è il metodo che sposta l'oggetto .... cmq uso un win form ... Framework 4.0codice:private void Sposta(string oggettoPadre,string oggettoDaSpostare, int OggettoDaSpostareX, int OggettoDaSpostareY) { //Se OggettoDaSpostareX e y sono più distanti dell'oggetto padre if (OggettoDaSpostareX > Controls[oggettoPadre].Location.X && OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareX > Controls[oggettoPadre].Location.X || OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); if (OggettoDaSpostareX > Controls[oggettoPadre].Location.X) OggettoDaSpostareX--; if (OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) OggettoDaSpostareY--; for (int i = 0; i < 2700000; i++) { } } } //Se y è più distante dell'oggetto padre e x è uguale if (OggettoDaSpostareX == Controls[oggettoPadre].Location.X && OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); OggettoDaSpostareY--; for (int i = 0; i < 2700000; i++) { Controls[oggettoDaSpostare].Refresh(); } } } // Se x è meno distante del contenitore padre e Y è + distante if (OggettoDaSpostareX < Controls[oggettoPadre].Location.X && OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareX < Controls[oggettoPadre].Location.X || OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); if (OggettoDaSpostareX < Controls[oggettoPadre].Location.X) OggettoDaSpostareX++; if (OggettoDaSpostareY > Controls[oggettoPadre].Location.Y) OggettoDaSpostareY--; for (int i = 0; i < 2700000; i++) { } } } //Se x è meno distante dell'oggetto padre e y è uguale if (OggettoDaSpostareX < Controls[oggettoPadre].Location.X && OggettoDaSpostareY == Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareX < Controls[oggettoPadre].Location.X) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); OggettoDaSpostareX++; for (int i = 0; i < 2700000; i++) { } } } //Se x e y sono meno distanti dell'oggetto padre if (OggettoDaSpostareX < Controls[oggettoPadre].Location.X && OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareX < Controls[oggettoPadre].Location.X || OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); if (OggettoDaSpostareX < Controls[oggettoPadre].Location.X) OggettoDaSpostareX++; if (OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) OggettoDaSpostareY++; for (int i = 0; i < 2700000; i++) { } } } //Se y è meno distante dell'oggetto padre e x è uguale if (OggettoDaSpostareX == Controls[oggettoPadre].Location.X && OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); OggettoDaSpostareY++; for (int i = 0; i < 2700000; i++) { } } } // Se x è più distante del contenitore padre e Y è meno distante if (OggettoDaSpostareX > Controls[oggettoPadre].Location.X && OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareX > Controls[oggettoPadre].Location.X || OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); if (OggettoDaSpostareX > Controls[oggettoPadre].Location.X) OggettoDaSpostareX--; if (OggettoDaSpostareY < Controls[oggettoPadre].Location.Y) OggettoDaSpostareY++; for (int i = 0; i < 2700000; i++) { } } } //Se x più meno distante dell'oggetto padre e y è uguale if (OggettoDaSpostareX > Controls[oggettoPadre].Location.X && OggettoDaSpostareY == Controls[oggettoPadre].Location.Y) { while (OggettoDaSpostareX > Controls[oggettoPadre].Location.X) { Controls[oggettoDaSpostare].Location = new Point(OggettoDaSpostareX, OggettoDaSpostareY); OggettoDaSpostareX--; for (int i = 0; i < 2700000; i++) { } } } }