R
R
Roman_20172017-10-19 15:06:47
C++ / C#
Roman_2017, 2017-10-19 15:06:47

There are two forms - in one variable i, in the second form 8 Labels, i must be written to the label that is equal to 0 how to implement it?

Initially, all labels have a value of 0, and we write i to the first label, then to the second, and so on.
The check should be done like if label1 = 0 then write i into it if not, then check label2 and so on until label8 (if it is busy, I wrote my solution)
i changes after the function is triggered (the game of tag gre i is a counter of moves made)
this is the part of the code where i wrote:

public partial class FormGame1 : Form
    {
        static public int i = 0;
        Game1 game;
        public FormGame1()
        {
            InitializeComponent();
            game = new Game1(4);
        }

        private void button7_Click_1(object sender, EventArgs e) //button7_Click_1 ето все 16 кнопок я выделил и задал им одно событие
        {
            i++;
            int position = Convert.ToInt32(((Button)sender).Tag);
            game.shift(position);
            refresh();
            if (game.check_numbers())
            {
                MessageBox.Show("Вы победили!  " + "Ходов :  "  + i + "!");
                start_game();
                i = 0;
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2017-10-19
@Morpheus_God

Try putting the label in the label[8] array or whatever you want. And there is an Array.Exists method.
https://msdn.microsoft.com/en-us/library/yw84x8be%...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question