elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Temas
Páginas: [1]
1  Programación / Programación General / Este código de C sharp no compila ni a tiros (post editado) en: 25 Diciembre 2013, 15:12 pm
Hola, llevo todo el fin de semana trabajando en este "hundir la Flota en Csharp" para que compile de una vez, pero siempre me salta algun error, vaya dolor de cabeza.
Me veo obligado a recurrir a vuestra experiencia para ver qué es lo que le falta y pueda presentárselo al profesor (un ser iracundo de por sí).

Editado: pongo aquí arriba el mensaje de error, que creo que es lo que quiere la moderación, porque si se trata de mover el hilo, no sé hacerlo.





"El método debe de tener un valor devuelto" (se refiere a lo de abajo):

        public Form1()
        {



            //



            // Requis pour la prise en charge du Concepteur Windows Forms



Código entero:


using System;


using System.Drawing;


using System.Collections;


using System.ComponentModel;


using System.Windows.Forms;


using System.Data;


namespace BatallaNaval
{



    /// <summary>



    /// Description résumée de Form1.



    /// </summary>



    public
    class Program
    {



        private System.Windows.Forms.PictureBox[,] tab;



        private System.Windows.Forms.PictureBox pbox_test;



        /// <summary>



        /// Variable nécessaire au concepteur.



        /// </summary>



        private System.ComponentModel.Container components =
        null;



        public Form1()
        {



            //



            // Requis pour la prise en charge du Concepteur Windows Forms



            //


            InitializeComponent();



            //



            // TODO : ajoutez le code du constructeur après l'appel à InitializeComponent



            //


        }



        /// <summary>



        /// Nettoyage des ressources utilisées.



        /// </summary>



        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



        /// <summary>



        /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas



        /// le contenu de cette méthode avec l'éditeur de code.



        /// </summary>



        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()
        {


            Form1 appli =
            new Form1();


            Application.Run(appli);




        }



        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[" + i + "," + j + "]";



                    this.tab[i, j].TabIndex = 0;



                    this.tab[i, j].BackColor = System.Drawing.Color.Green;



                    this.tab[i, j].Click +=
                    new System.EventHandler(
                    this.cmdTab_Click);



                    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 cmdTab_Click(
        object sender, System.EventArgs e)
        {


            pbox_test.BackColor = Color.Cyan;


            PictureBox PB = (PictureBox)sender;




            PB.BackColor = Color.Cyan;


        }


    }


}
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines