-2

in c# how can i repeat a code that i write in a form key down event each time i press that key i mean i want to re run that code each time i press the key i think this can be so simple for u cause i am beginner thanks this code is what i already tried

if (e.KeyCode == Keys.Down)

        {

            textBox1.TabStop = true;
            dataGridView1.Focus();
            label1.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();



        }
s952163
  • 6,276
  • 4
  • 23
  • 47

1 Answers1

1

The key_down code should just repeat and loop around every time the assigned key is pressed, as the subroutine is just called over and over again on every key down event.

David
  • 2,298
  • 6
  • 22
  • 56
  • But it will not be repeated when i pressed the key – A programmer Jul 15 '16 at 09:39
  • 1
    Yes, it will be executed again, if you press the key again. – L-Four Jul 15 '16 at 10:05
  • @Aprogrammer as said above, it is executed each time you press the key. Have you tried this? If so, try pressing it again but leave a longer time after pressing it before doing so again. If it still doesn't work then something is wrong. – David Jul 15 '16 at 10:12