Déplacement de picturebox [Résolu]

KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 22 déc. 2011 à 16:41 - Dernière réponse : KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention
- 23 déc. 2011 à 17:20
Bonjour,

Je me test au déplacement d'objet, et ne comprend pas pourquoi le déplacement de gauche à droite est fluide, mais de haut en bas ou vice-versa, la picturebox clignote et avance en diagonal.
Pouvez-vous m'éclairer ?

Merci.

    Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If e.KeyCode = Keys.Left Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 5, Me.PictureBox1.Location.Y)
        End If
        If e.KeyCode = Keys.Right Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 5, Me.PictureBox1.Location.Y)
        End If
        If e.KeyCode = Keys.Up Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.Y - 5, Me.PictureBox1.Location.X)
        End If
        If e.KeyCode = Keys.Down Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.Y + 5, Me.PictureBox1.Location.X)
        End If
    End Sub

End Class
Afficher la suite 

Votre réponse

21 réponses

Meilleure réponse
Utilisateur anonyme - 22 déc. 2011 à 18:52
3
Merci
Bonsoir,

Un point s'écrit en coordonnées x,y.
Dans ton code, ton point est de la forme y,x.
Inverse les et tout rentrera dans l'ordre.

Merci Utilisateur anonyme 3

Avec quelques mots c'est encore mieux Ajouter un commentaire

Codes Sources a aidé 80 internautes ce mois-ci

Commenter la réponse de Utilisateur anonyme
Meilleure réponse
NHenry 14229 Messages postés vendredi 14 mars 2003Date d'inscription 14 juillet 2018 Dernière intervention - 22 déc. 2011 à 18:56
3
Merci
Bonjour,

Tu es sûr que X et Y sont dans le bon ordre ?
New System.Drawing.Point(Me.PictureBox1.Location.Y - 5, Me.PictureBox1.Location.X)

Pour le clignotement, intéresses-toi au double buffering.

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---

Merci NHenry 3

Avec quelques mots c'est encore mieux Ajouter un commentaire

Codes Sources a aidé 80 internautes ce mois-ci

Commenter la réponse de NHenry
Meilleure réponse
NHenry 14229 Messages postés vendredi 14 mars 2003Date d'inscription 14 juillet 2018 Dernière intervention - 22 déc. 2011 à 20:08
3
Merci
Bonjour,

Il faut que tu contrôle la position X et Y (et éventuellement la taille de la PictureBox).

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---

Merci NHenry 3

Avec quelques mots c'est encore mieux Ajouter un commentaire

Codes Sources a aidé 80 internautes ce mois-ci

Commenter la réponse de NHenry
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 22 déc. 2011 à 19:58
0
Merci
Bonsoir,

Merci bien, effectivement j'avais pas inversé comme il fallais héhé.

Résolu merci à vous.

Public Class Form1

  Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If e.KeyCode = Keys.Left Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 5, Me.PictureBox1.Location.Y)
        End If
        If e.KeyCode = Keys.Right Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 5, Me.PictureBox1.Location.Y)
        End If
        If e.KeyCode = Keys.Up Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 5)
        End If
        If e.KeyCode = Keys.Down Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 5)
        End If
    End Sub

End Class
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 22 déc. 2011 à 20:02
0
Merci
Est-il possible de mettre des limites (barrières) à la picture box ?
Pour fabriquer un labyrinthe par exemple.
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 22 déc. 2011 à 20:10
0
Merci
Ok merci je pensais bien que ce ne serai pas tâches facile.
En + la position pourrai changer si la fenêtre est redimensionné.
Merci pour cet éclaircissement.
Commenter la réponse de KcHeY
Utilisateur anonyme - 22 déc. 2011 à 20:17
0
Merci
Interesse toi aussi à la classe Rectangle qui te permet facilement de tester si un objet rectangulaire recoupe un autre objet rectangulaire :
If Rectangle.Intersect(picturebox1.bounds, picturebox2.bounds) <> Rectangle.Empty Then ...
Commenter la réponse de Utilisateur anonyme
Utilisateur anonyme - 22 déc. 2011 à 20:30
0
Merci
Exemple (à rajouter à ton code plus haut) :
If Rectangle.Intersect(PictureBox1.Bounds, Me.ClientRectangle) <> PictureBox1.Bounds Then
  MessageBox.Show("picturebox1 est sorti du formulaire")
End If
Commenter la réponse de Utilisateur anonyme
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 22 déc. 2011 à 20:35
0
Merci
Bonsoir,

Merci pour cette info très utile.
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 12:58
0
Merci
Le format image .PNG est-il pris en compte pour une picturebox ?
Je ne parviens pas à afficher mon image.
Je souhaiterai animer une araignée.
J'ai créé 12 images.
4 images 1 déplacement.
je souhaiterai qu'au moment ou je déplace mon araignée, 4 images s'enchaine comme un gif.
Donc j'imagine que sa pourrai donner ça :

 
If e.KeyCode = Keys.Up Then
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
PictureBox1.image = my.resources.a1
Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
PictureBox1.image = my.resources.a2
Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
PictureBox1.image = my.resources.a3
Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
PictureBox1.image = my.resources.a4
        End If


Le soucis c'est que mon image ne s'affiche pas dans la picturebox.
Le format PNG et la transparence des images ne sont-elles pas pris en compte?
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 12:59
0
Merci
Oh tellement la tête dans l'araignée que je n'ai pas dis bonjour ^^

Bonjour !
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 13:03
0
Merci
Apparement non car mêmeavec un jpg mon image ne s'affiche pas.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PictureBox1.Image = My.Resources.aa1
    End Sub
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 13:13
0
Merci
Je précise que même si j'essai d'ajouter manuellement l'image ou le backroundimage depuis l'interface de propriété, cela ne fonctionne pas..
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 13:17
0
Merci
Désolé je fais que d'éditer mais je viens de me rendre compte que je ne peux même plus mettre d'image sur un bouton...
Vous avez une idée d'où viens ce soucis ?
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 13:34
0
Merci
Roooh il fallais que je mette la proriété de l'image à stretch. :p
@ bientôt.
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 14:05
0
Merci
Re,

Voici mon idée (qui ne fonctionne pas).
J'ai aussi essayer en faisant une suite de IF, de ELSEIF.. mais rien a faire.

        If e.KeyCode = Keys.NumPad8 Then   'haut
            Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 5)
            If PictureBox1.BackgroundImage Is My.Resources.a1 Then
                PictureBox1.BackgroundImage = My.Resources.a2
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a2 Then
                PictureBox1.BackgroundImage = My.Resources.a3
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a3 Then
                PictureBox1.BackgroundImage = My.Resources.a4
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a4 Then
                PictureBox1.BackgroundImage = My.Resources.a5
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a5 Then
                PictureBox1.BackgroundImage = My.Resources.a6
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a6 Then
                PictureBox1.BackgroundImage = My.Resources.a7
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a7 Then
                PictureBox1.BackgroundImage = My.Resources.a8
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a8 Then
                PictureBox1.BackgroundImage = My.Resources.a9
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a9 Then
                PictureBox1.BackgroundImage = My.Resources.a10
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a10 Then
                PictureBox1.BackgroundImage = My.Resources.a11
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a11 Then
                PictureBox1.BackgroundImage = My.Resources.a12
            ElseIf PictureBox1.BackgroundImage Is My.Resources.a12 Then
                PictureBox1.BackgroundImage = My.Resources.a1
            End If
            End If
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 14:38
0
Merci
Comme ceci non plus :

If e.KeyCode = Keys.NumPad8 Then   'haut
            If PictureBox1.BackgroundImage.Equals(My.Resources.a1) Then
                PictureBox1.BackgroundImage = My.Resources.a2
                PictureBox1.BackgroundImage = My.Resources.a2
                PictureBox1.BackgroundImage = My.Resources.a3
                PictureBox1.BackgroundImage = My.Resources.a4
                PictureBox1.BackgroundImage = My.Resources.a5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 5)

                If PictureBox1.BackgroundImage.Equals(My.Resources.a5) Then
                    PictureBox1.BackgroundImage = My.Resources.a6
                    PictureBox1.BackgroundImage = My.Resources.a7
                    PictureBox1.BackgroundImage = My.Resources.a8
                    PictureBox1.BackgroundImage = My.Resources.a9
                    Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 5)

                    If PictureBox1.BackgroundImage.Equals(My.Resources.a9) Then
                        PictureBox1.BackgroundImage = My.Resources.a10
                        PictureBox1.BackgroundImage = My.Resources.a11
                        PictureBox1.BackgroundImage = My.Resources.a12
                        PictureBox1.BackgroundImage = My.Resources.a1
                    End If
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 14:56
0
Merci
Yes j'ai reussi !
Il fallais déclarer toute mes ressources en haut de page ^^
Merci !!!!!!!!
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 16:17
0
Merci
Bonsoir !
Voici mon code final qui controle l'araigné avec les touches du pavé numérique.
Une chose me dérange dans tout ça, c'est que quand je reste appuyé, l'araigné va trop vite, pouvons nous régler les images par secondes ?
Cordialement.
Commenter la réponse de KcHeY
KcHeY 261 Messages postés dimanche 23 mai 2004Date d'inscription 22 septembre 2012 Dernière intervention - 23 déc. 2011 à 16:21
0
Merci
Oups le voici.

Public Class Form1
    Dim pas1 As Image = My.Resources.a1
    Dim pas2 As Image = My.Resources.a2
    Dim pas3 As Image = My.Resources.a3
    Dim pas4 As Image = My.Resources.a4
    Dim pas5 As Image = My.Resources.a5
    Dim pas6 As Image = My.Resources.a6
    Dim pas7 As Image = My.Resources.a7
    Dim pas8 As Image = My.Resources.a8
    Dim pas9 As Image = My.Resources.a9
    Dim pas10 As Image = My.Resources.a10
    Dim pas11 As Image = My.Resources.a11
    Dim pas12 As Image = My.Resources.a12
    Dim pas13 As Image = My.Resources.a13
    Dim pas14 As Image = My.Resources.a14
    Dim pas15 As Image = My.Resources.a15
    Dim pas16 As Image = My.Resources.a16

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PictureBox1.BackgroundImage = pas1
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If Rectangle.Intersect(PictureBox1.Bounds, Me.ClientRectangle) <> PictureBox1.Bounds Then
            MessageBox.Show("picturebox1 est sorti du formulaire")
        End If

        If e.KeyCode = Keys.NumPad8 Then   'haut
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y - 1)
            End If
         End If

        If e.KeyCode = Keys.NumPad2 Then  'bas
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X, Me.PictureBox1.Location.Y + 1)
            End If
        End If

        If e.KeyCode = Keys.NumPad4 Then 'left
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y)
            End If
        End If




        If e.KeyCode = Keys.NumPad6 Then 'right
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y)
            End If
        End If





        If e.KeyCode = Keys.NumPad9 Then  'haut droit
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y - 1)
            End If
        End If




        If e.KeyCode = Keys.NumPad7 Then  'haut gauche
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y - 1)
            End If
        End If



        If e.KeyCode = Keys.NumPad3 Then  'bas droit
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X + 1, Me.PictureBox1.Location.Y + 1)
            End If
        End If



        If e.KeyCode = Keys.NumPad1 Then  'bas gauche
            If PictureBox1.BackgroundImage Is Me.pas1 Then
                PictureBox1.BackgroundImage = pas2
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas3
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas4
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas5
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas5 Then
                PictureBox1.BackgroundImage = pas6
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas7
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas8
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas9
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas9 Then
                PictureBox1.BackgroundImage = pas10
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas11
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas12
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas13
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)

            ElseIf PictureBox1.BackgroundImage Is Me.pas13 Then
                PictureBox1.BackgroundImage = pas14
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas15
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas16
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
                PictureBox1.BackgroundImage = pas1
                Me.PictureBox1.Location = New System.Drawing.Point(Me.PictureBox1.Location.X - 1, Me.PictureBox1.Location.Y + 1)
            End If
        End If
    End Sub



End Class
Commenter la réponse de KcHeY

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.

Déplacement de picturebox - page 2