using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Bataille_navale_g { public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.PictureBox [,] tab; private System.Windows.Forms.PictureBox pbox_test; private System.ComponentModel.Container components = null; public Form1() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Code généré par le Concepteur Windows Form private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager ( typeof(Form1)); this.pbox_test = new System.Windows.Forms.PictureBox(); this.SuspendLayout(); // pbox_test this.pbox_test.BackColor = System.Drawing.Color.Red; this.pbox_test.Location = new System.Drawing.Point(712, 16); this.pbox_test.Name = "pbox_test"; this.pbox_test.Size = new System.Drawing.Size(32, 24); this.pbox_test.TabIndex = 0; this.pbox_test.TabStop = false; this.pbox_test.DoubleClick += new System.EventHandler( this.pbox_test_DoubleClick); // Form1 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); this.ClientSize = new System.Drawing.Size(760, 494); this.Controls.Add( this.pbox_test); this.Cursor = System.Windows.Forms.Cursors.Default; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.MaximizeBox = false; this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler( this.Form1_Load); this.ResumeLayout( false); } #endregion /// <summary> /// Point d'entrée principal de l'application. /// </summary> [STAThread] static void Main() { Application.Run( new Form1()); } private void Form1_Load( object sender, System.EventArgs e) { //Création du tableau de picture Box this.tab = new System.Windows.Forms.PictureBox[9,9]; for( int j=0;j<8;j++) { int i; for(i=0;i<9;i++) { this.tab[i,j]= new PictureBox(); this.tab[i,j].Size= new System.Drawing.Size(40, 40); this.tab[i,j].Location = new System.Drawing.Point(i*50+125, j*50+70); this.tab[i,j].Name = "Tab"; this.tab[i,j].TabIndex = 0; this.tab[i,j].BackColor = System.Drawing.Color.Green; this.Controls.Add( this.tab[i,j]); } i=0; } } private void pbox_test_DoubleClick( object sender, System.EventArgs e) { pbox_test.BackColor=Color.Blue; tab[2,1].BackColor=Color.Blue; } private void tab_DoubleClick( object sender, System.EventArgs e) { pbox_test.BackColor=Color.Blue; tab[0,0].BackColor=Color.Blue; } } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question