int Y =0; for (i = 0; i < nbLignes; i++) { int j = 0; int X = 0; Y = Y + 39; for (j = 0; j < nbColonnes; j++) { X += 35; tabDem[i,j] = new PictureBox(); // création de la pictureBox dans le tableau //tabDem[i, j].Name = "pb" + i.ToString() + j.ToString(); tabDem[i, j].Location = new Point(X, Y); tabDem[i,j].Size = new Size(20, 20); tabDem[i, j].BorderStyle = BorderStyle.Fixed3D; //tabDem[i,j].Image = Properties.Resources.fond ; tabDem[i, j].Visible = true; this.Controls.Add(tabDem[i, j]); //MessageBox.Show(tabDem[i, j].Name.ToString()); } }
this.Controls.Add(pb); // car j'ai fais plus haut pb = new PictureBox();
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic class PictureBoxImageAdding : System.Windows.Forms.Form
public partial class WebForm1 : System.Web.UI.Page
PictureBox[,] tabDem = new PictureBox[nbLignes, nbColonnes]; // Tableau pour mettre les picturebox int Y = 0; for (i = 0; i < nbLignes; i++) { int X = 0; Y = Y + 39; // incrémentation de la pictureBox vers le bas for (j = 0; j < nbColonnes; j++) { X += 35; tabDem[i,j] = new PictureBox(); // création de la pictureBox dans le tableau tabDem[i, j].Location = new Point(X, Y); // Mise en place de la pictureBox tabDem[i,j].Size = new Size(20, 20); // Définition de la taille de la pictureBox tabDem[i, j].BorderStyle = BorderStyle.Fixed3D; // Mise de bordure aux pictureBox tabDem[i,j].Image = Properties.Resources.fond ; // Mise en place de l'image dans la pictureBox tabDem[i, j].Visible = true; // Rendre la pictureBox visible this.Controls.Add(tabDem[i,j]); } }