Movement by specific keys (event KeyPress does not receive Enter)

0

I have a sales form in which the user can go through the sales adding items until the sale ends.

I want you to press the key to change the attribute enabled of an element and pass the focus to it.

This is what I tried:

 private void ventapiezas_KeyPress(object sender, KeyPressEventArgs e)
    {
        if(e.KeyChar == Convert.ToChar(Keys.Enter))
        {
            txtefectivo.Enabled = true;
            txtefectivo.Focus();
        }

    }

But it does not work, it does not display error. ventapiezas is the form

    
asked by Samuel Ignacio Susana Confesor 06.08.2017 в 05:47
source

1 answer

1

The arguments of KeyPress do not report if enter was pressed, use KeyUp instead.

    private void ventapiezas_KeyUp(object sender, KeyEventArgs e) {
        if(e.KeyCode == Keys.Enter) {

            //Tu accion

            }
        }
    
answered by 06.08.2017 / 20:43
source