none
exchange backspace with delete

    Question

  • Is there any way to exchange backspace with delete key. I hav used this code in key_down event of rtb
    if e.KeyCode = Keys.Back then
       SendKeys.Send ("{DELETE}")
    endif
    but now it  works as both backspace and delete.

    Tuesday, July 07, 2009 5:03 AM

Answers

  • see if using e.SupressKeyPress works how you want

    Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
            If e.KeyCode = Keys.Back Then
                e.SuppressKeyPress = True
                SendKeys.Send("{DELETE}")
            End If
    
        End Sub
    • Proposed as answer by jwavila Tuesday, July 07, 2009 7:46 PM
    • Marked as answer by Calwar Wednesday, July 08, 2009 3:21 AM
    Tuesday, July 07, 2009 5:51 AM

All replies

  • see if using e.SupressKeyPress works how you want

    Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
            If e.KeyCode = Keys.Back Then
                e.SuppressKeyPress = True
                SendKeys.Send("{DELETE}")
            End If
    
        End Sub
    • Proposed as answer by jwavila Tuesday, July 07, 2009 7:46 PM
    • Marked as answer by Calwar Wednesday, July 08, 2009 3:21 AM
    Tuesday, July 07, 2009 5:51 AM
  • Calwar,
    jwavila's code will work just fine, however, I would advice you to rethink this. I surely don't know anything about your application but the BACKSPACE key is BACKSPACE for a reason; remapping it within a user control such as a RichTextBox control might cause confusion for the user, so, imho it would be wise sticking with standards.

    Just my 2 cents though ... ! :-)
    Listing SPEC's is not a review !!! :-)
    Tuesday, July 07, 2009 5:56 AM
  • thnx jwavila. I needed this for urdu editor.
    Wednesday, July 08, 2009 3:21 AM