protected override void OnKeyDown(KeyEventArgs args) { if (CanTextCommit != null && (args.Key == Keys.RETURN || args.Key == Keys.NUMPADENTER)) { var canArgs = new CanCommitEventArgs { Cancel = false }; CanTextCommit(this, canArgs); if (canArgs.Cancel) return; } base.OnKeyDown(args); }
void Binding_CanTextCommit(object sender, CanCommitEventArgs e) { try { SourcePropertyChanged(sender, null); } catch (FormatException) { e.Cancel = true; } }