Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm in a multiline text box. I am using a button to backspace, which works fine for whatever line I happen to be on. When I say backspace, I'm deleting characters as I go.

When I get to the start position of (line 3 for example, it could be 2 or 5. It does the same thing on all but the first line), and click the back button again, the program freezes up for about 40 seconds, and then I can use it again. I would expect it just jump up to the end of the next line, the same as hitting the backspace on a keyboard would do.

What I have tried:

I don't get any errors. I've tried stepping through the code to try and see what's occurring at that point but nothing is showing.

private void BtnBack_Click(object sender, EventArgs e)
       {
           if (txtFCF.SelectionStart > 0)
           {
               int index = txtFCF.SelectionStart;
               txtFCF.Text = txtFCF.Text.Remove(txtFCF.SelectionStart - 1, 1);
               txtFCF.Select(index - 1, 1);
           }
       }
Posted
Updated 20-Jun-19 10:54am

1 solution

Try this:
private void BtnBack_Click(object sender, EventArgs e)
{
   txtFCF.Focus(); 
   SendKeys.Send("{BACKSPACE}");
}
 
Share this answer
 
Comments
Smeezy 21-Jun-19 7:06am    
I spent the last month trying to figure this out (that's probably the real cost of software right there)! Thank you so much Bill!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900