Domanda

I use a MaskedTextBox control to facilitate the entry of dates in my project. I have mtb.BeepOnError set to false. However, it makes a generic beep whenever the 'Enter' key or 'Esc' key is pressed, and this is undesirable for my application.

This seems to be the default behaviour for the MTB, so is there any way to change that?

È stato utile?

Soluzione

You can try something like this:

void mtb_KeyDown(object sender, KeyEventArgs e) {
  if (e.KeyCode == Keys.Enter | e.KeyCode == Keys.Escape) {
    e.SuppressKeyPress = true;
  }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top