I want to make program with C# that can to know how many times user using key "backspace". This is the scenario, User will typing in richtextbox, after they finished typing, I want to know from begining until they press enter, how many time they used "backspace". That information will show up in messagebox like "Backspace used 10 time". Please help me
Asked
Active
Viewed 329 times
-2
-
3What have you tried so far? – Ecordero Aug 28 '18 at 17:34
-
The problem with questions like these is we don't know where you're starting from, what you have, or what you're stuck on. Do you have any richTextBox code at all? Post it. Is it for WinForms? ASP.NET? WPF? UWP? . – Dour High Arch Aug 28 '18 at 17:43
-
this is what I tried so far - private void richTextBox1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Back) { MessageBox.Show("Enter Backspace"); } } – Esang Aug 28 '18 at 18:28
-
thank you for give me a comment, it's work now.. I find the solution – Esang Aug 28 '18 at 18:39
1 Answers
2
You can use KeyDown
event to count the keys pressed, so it'll be something like the code below.
int count = 0;
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.BackSpace)
count++;
else if (e.KeyCode == Keys.Enter)
//Show Message.
}

J3soon
- 3,013
- 2
- 29
- 49