IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Visual Studio Discussion :

Bouton pour générer une picturebox


Sujet :

Visual Studio

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Gamer
    Inscrit en
    Février 2015
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vosges (Lorraine)

    Informations professionnelles :
    Activité : Gamer

    Informations forums :
    Inscription : Février 2015
    Messages : 5
    Points : 1
    Points
    1
    Par défaut Bouton pour générer une picturebox
    Bonjour,
    je souhaiterais créer un logiciel qui permet que lorsque l'on clique sur les boutons le smiley adéquat au bouton s'affiche dans une picture box, et si l'on clique sur un autre bouton les smiley se suivent en dessous.

    J'ai déjà fais toute la partie graphique, voici un screen avec des explications :
    Nom : Sans titre 1.png
Affichages : 206
Taille : 56,3 Ko

    J'ai essayé ce code mais il me dis que sourire.png n'est pas déclaré (j'ai déjà importer mes images dans Visual Basic..) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(22, 199)
            p.Size = New Drawing.Size(75, 52)
            p.BorderStyle = Windows.Forms.BorderStyle.Fixed3D
            p.Visible = True
            p.Image = (sourire.png)
            Me.Controls.Add(p)
        End Sub
    Autre chose, j'ai trouvé 2 problème auxquels faire face :
    Problème : L'ordre n'est jamais le même, donc il faut trouver un moyen de créer la picturebox aux bonnes coordonnées
    Problème 2 : Il se peut que j'ai à cliquer 2 fois sur le même bouton, le smiley devra donc s'afficher 2 fois

    Merci d'avance pour votre aide !

  2. #2
    Expert éminent Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Points : 7 903
    Points
    7 903
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    p.Image = Button1.Image ;
    " Le croquemitaine ! Aaaaaah ! Où ça ? " ©Homer Simpson

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Gamer
    Inscrit en
    Février 2015
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vosges (Lorraine)

    Informations professionnelles :
    Activité : Gamer

    Informations forums :
    Inscription : Février 2015
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    ca marches parfaitement, voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(22, 199)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button1.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
    comment puis-je faire pour les aligner côte à côte peu importe l'ordre?
    Et faire en sorte de pouvoir mettre deux fois de suite le même smiley

  4. #4
    Expert éminent Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Points : 7 903
    Points
    7 903
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    p.Location = New Drawing.Point(22+(75+MargeSeparantLesBoutonsCrees)*IndexDuBoutonCree, 199)
    " Le croquemitaine ! Aaaaaah ! Où ça ? " ©Homer Simpson

  5. #5
    Nouveau Candidat au Club
    Homme Profil pro
    Gamer
    Inscrit en
    Février 2015
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vosges (Lorraine)

    Informations professionnelles :
    Activité : Gamer

    Informations forums :
    Inscription : Février 2015
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    bonsoir, seul les 2 premier boutons fonctionnent, et de manière étrange :

    Nom : fffffff.png
Affichages : 114
Taille : 54,5 Ko

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    Public Class Form1
     
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(128 + (75 + 10) * 2, 217)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button2.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(47 + (75 + 10) * 1, 217)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button1.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(47 + (75 + 10) * 11, 367)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button11.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(209 + (75 + 10) * 3, 217)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button3.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(290 + (75 + 10) * 4, 217)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button4.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(371 + (75 + 10) * 5, 217)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button5.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(47 + (75 + 10) * 6, 298)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button6.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(128 + (75 + 10) * 7, 298)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button7.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(209 + (75 + 10) * 8, 298)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button8.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(290 + (75 + 10) * 9, 298)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button9.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(371 + (75 + 10) * 10, 298)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button10.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(128 + (75 + 10) * 12, 367)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button12.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(209 + (75 + 10) * 13, 367)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button13.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(290 + (75 + 10) * 14, 367)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button14.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
            Dim p As New Windows.Forms.PictureBox()
            p.Location = New Drawing.Point(371 + (75 + 10) * 15, 367)
            p.Size = New Drawing.Size(75, 52)
            p.Visible = True
            p.Image = Button15.Image
            p.SizeMode = PictureBoxSizeMode.CenterImage
            Me.Controls.Add(p)
        End Sub
     
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        End Sub
    End Class
    merci beaucoup pour toute cette aide !

  6. #6
    Nouveau Candidat au Club
    Homme Profil pro
    Gamer
    Inscrit en
    Février 2015
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vosges (Lorraine)

    Informations professionnelles :
    Activité : Gamer

    Informations forums :
    Inscription : Février 2015
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    serait-il possible d'ajouter un bouton pour effacer toute les picturebox ?

  7. #7
    Nouveau Candidat au Club
    Homme Profil pro
    Gamer
    Inscrit en
    Février 2015
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Vosges (Lorraine)

    Informations professionnelles :
    Activité : Gamer

    Informations forums :
    Inscription : Février 2015
    Messages : 5
    Points : 1
    Points
    1
    Par défaut
    De l'aide s'il vous plait

Discussions similaires

  1. Réponses: 6
    Dernier message: 13/11/2007, 10h59
  2. Un 3ème bouton pour ouvrir une page
    Par philippef dans le forum Balisage (X)HTML et validation W3C
    Réponses: 1
    Dernier message: 10/11/2006, 15h36
  3. [VB.NET] Clic sur un bouton pour afficher une form existante
    Par beegees dans le forum Windows Forms
    Réponses: 2
    Dernier message: 09/06/2006, 10h31
  4. Réponses: 3
    Dernier message: 02/12/2005, 13h23
  5. Réponses: 1
    Dernier message: 14/10/2005, 09h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo