MES Keypress Event

I’m trying to set up a keypress event on the MES screen to use to read a barcode scanner. I’ve done this on other screens, but I can’t get the event to fire in MES. Any thoughts? My code is below. The funny thing is sometimes after I open up customization to edit it I get the VPN events to fire.

public void InitializeCustomCode()
{

    Erp.Menu.Mes.MESMenu panel = MESMenu;
    panel.KeyDown += new KeyEventHandler(panel_KeyDown);
    panel.KeyPress += new KeyPressEventHandler(panel_KeyPress);
    panel.KeyUp += new KeyEventHandler(panel_KeyUp);
	MessageBox.Show("KeyPressEventHandler Created");

}
    private void panel_KeyDown(object sender, KeyEventArgs e)
    {
		MessageBox.Show("panel_KeyDown");


    }
    private void panel_KeyPress(object sender, KeyPressEventArgs e)
    {
		MessageBox.Show("panel_KeyPress");


    }
    private void panel_KeyUp(object sender, KeyEventArgs e)
    {
		MessageBox.Show("panel_KeyUp");


    }
1 Like

You probably need to enable KeyPreview on the MES Form.

That was it.
Thanks! I would have sworn I tried that. I probably tried it one control level down on a control that didn’t support KeyPreview.