protected override void OnKeyDown(KeyEventArgs e) { char c = (char)e.KeyCode; switch (e.KeyCode) { case Keys.NumPad7: c = '7'; break; case Keys.NumPad8: c = '8'; break; case Keys.NumPad9: c = '9'; break; } if (c.IsLetterOrDigit() && !MacAddressHelper.IsAllowed(c)) { if (e.Modifiers == Keys.None || c != 'C' && c != 'X' && c != 'V') { e.Handled = true; e.SuppressKeyPress = true; return; } } base.OnKeyDown(e); }
protected override void OnKeyPress(KeyPressEventArgs e) { if (!MacAddressHelper.IsAllowed(e.KeyChar)) { return; } base.OnKeyPress(e); }