void maMethode(object sender, EventArgs e)
Pour cela, lorsque j'instancie une PictureBox, je crée un nouvel event qui renvoi à la méthode ClickPictureBox.
private void InitImagePiece(int iLigne, int iColonne, Image imPiece) { this.tabImageCase[iLigne, iColonne].PictureBoxPiece = new PictureBox(); this.tabImageCase[iLigne, iColonne].PictureBoxPiece.Parent = this.tabImageCase[iLigne, iColonne].PictureBoxCase; this.tabImageCase[iLigne, iColonne].PictureBoxPiece.Image = imPiece; this.tabImageCase[iLigne, iColonne].PictureBoxPiece.BackColor = Color.Transparent; this.tabImageCase[iLigne, iColonne].PictureBoxPiece.Location = new Point(((this.iSize- imPiece.Width)/2), ((this.iSize - imPiece.Height) / 2)); this.tabImageCase[iLigne, iColonne].PictureBoxPiece.Width = imPiece.Width; this.tabImageCase[iLigne, iColonne].PictureBoxPiece.Height = imPiece.Height; this.tabImageCase[iLigne, iColonne].PictureBoxPiece.BringToFront(); this.tabImageCase[iLigne, iColonne].bPresencePiece = true; this.tabImageCase[iLigne, iColonne].PictureBoxPiece.Click += new System.EventHandler(this.DetectClick); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprivate void DetectClick(object sender, EventArgs e) { PictureBox p = (PictureBox)sender; }