using System.Linq; using System.Windows.Forms; namespace JD.WinFormExtensions { public static class TextBoxEditionHelper { public static bool DefaultIsKeyHandled(Keys keyModifiers, Keys keyCode) { if (keyModifiers == Keys.Control && keyCode.IsIn(Keys.A, Keys.C, Keys.V, Keys.X, Keys.Y, Keys.Z)) { return true; } return (keyModifiers == Keys.None || keyModifiers == Keys.Shift) && (keyCode < Keys.F1 || keyCode > Keys.F12); } private static bool IsIn(this T value, params T[] set) { return set.Contains(value); } /// /// Which numeric keys are handled on a numeric control. /// public static bool DefaultIsNumericKeyHandled(Keys keyModifiers, Keys keyCode) { bool handled = DefaultIsKeyHandled(keyModifiers, keyCode); // Alpha keys are not handled by the numeric up down. if (handled && keyModifiers == Keys.None && keyCode >= Keys.A && keyCode <= Keys.Z) { handled = false; } return handled; } } }