Answering a follow-up Question:
This is one of the ways to emulate backspace:
myButton.Click += (sender, eventArgs) => {
myTextBox.Focus();
Application.DoEvents();
SendKeys.Send("{BACKSPACE}");
};
Warning! Avoid using
Application.DoEvents
for other cases; one common mistake is doing it periodically as a dirty substitute of threading.
A variant without
SendKeys
:
myButton.Click += (sender, eventArgs) => {
int currentPosition = myTextBox.SelectionStart;
if (currentPosition > 0)
myTextBox.Text = myTextBox.Text.Remove(currentPosition - 1, 1);
};
—SA