void textBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) // Process the Delete key (since it is not passed on to the KeyPress event handler)... { TextBox tb = (TextBox)sender; if (!tb.ReadOnly) { LookupTablePicker ltp = new LookupTablePicker(_sharedUtils, tb.Tag.ToString(), ((DataRowView)_bindingSource.Current).Row, tb.Text); ltp.StartPosition = FormStartPosition.CenterParent; if (DialogResult.OK == ltp.ShowDialog()) { tb.Text = ltp.NewValue.Trim(); } e.Handled = true; } } }
void textBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != Convert.ToChar(Keys.Escape)) // Ignore the Escape key and process anything else... { TextBox tb = (TextBox)sender; if (!tb.ReadOnly) { LookupTablePicker ltp = new LookupTablePicker(_sharedUtils, tb.Tag.ToString(), ((DataRowView)_bindingSource.Current).Row, tb.Text); ltp.StartPosition = FormStartPosition.CenterParent; if (DialogResult.OK == ltp.ShowDialog()) { tb.Text = ltp.NewValue.Trim(); } e.Handled = true; } } }