BEEP on form instance creation. Keydown suppressed already

113 views Asked by At

I have a text box which creates a form when enter is pressed. It is a single line textbox.

I have suppressed the keypress and using breakpoints I have determined that the "BEEP" that is being played comes when I create a form instance...

 private void txtcust_KeyDown(object sender, KeyEventArgs e)
    {
        string searchtext;
        if (e.KeyCode == Keys.Enter)
        {
            searchtext = txtcust.Text;
            e.SuppressKeyPress = true;

            frmcustlist frmcust = new frmcustlist(searchtext);
            frmcust.ShowDialog();

        }

    }

The beep gets played after this code plays:

frmcustlist frmcust = new frmcustlist(searchtext);

I have tried numerous things including handling the key up, playing with AcceptsReturn and also multiline. Multiline works if TRUE, but then obviously the textbox now has 2 lines. Surely this isn't the answer??

Thanks for any advice Gangel

UPDATE: Added e.handled - Still got a beep/

private void txtcust_KeyDown(object sender, KeyEventArgs e)
    {
        string searchtext;
        if (e.KeyCode == Keys.Enter)
        {
            searchtext = txtcust.Text;
            e.SuppressKeyPress = true;
            e.Handled = true;


            frmcustlist frmcust = new frmcustlist(searchtext);
            frmcust.ShowDialog();

        }

    }
0

There are 0 answers