0

I have a Janus GridEx on cell updating I am checking for some condition and raise a message if the condition is met, what happens is that if the user pressed enter using the keyboard then the dialog will close and the enter press is passed to the grid ,so the message will show again since on enter press the cells of the grid will be updated, this situation will keep looping until I press the OK button of the dialog form by mouse button.

How can I stop the event pressed on the dialog box to be passed again to the grid?

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Hasan Shouman
  • 2,162
  • 1
  • 20
  • 26
  • You can unregister the event handler. You could use a syntax like `Event -= OnEventHandler;` when you want to stop listening for the event (inside a different if-check). – ryanyuyu Feb 26 '15 at 15:01

1 Answers1

1

You may mark the event as handled to prevent propagation. Example code:

private void OnKeyPressed(Object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == (char)Keys.Return)
    {
        e.Handled = true; // <--
    }
}
B.K.
  • 9,982
  • 10
  • 73
  • 105