Results 1 to 4 of 4

Thread: Disable the effect of DEL key.

  1. #1

    Thread Starter
    Addicted Member samkud's Avatar
    Join Date
    Oct 2001
    Location
    India
    Posts
    171

    Disable the effect of DEL key.

    Hi Guys,

    Is there anyway by which I can disable the effect of DEL key using VB.Net. I am developing a desktop application. What I want is the user should not be able to del key or ctrl-X or ctrlC when the focus is on the text box.

    Any answers?

    Please let me know.

    Regards,

    Samir.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Disable the effect of DEL key.

    VB Code:
    1. Private Sub MyTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    2.         If e.KeyCode = Keys.Delete Then
    3.  
    4.         End If
    5.         If e.Control And e.KeyCode = Keys.C Then
    6.  
    7.         End If
    8.         If e.Control And e.KeyCode = Keys.V Then
    9.  
    10.         End If
    11.     End Sub
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Addicted Member samkud's Avatar
    Join Date
    Oct 2001
    Location
    India
    Posts
    171

    Re: Disable the effect of DEL key.

    Thanx a lot buddy.

    I tried the same thing but it didn't work. Probaby because i traped the keypress and the keyup events.

    Regards,

    Samir.

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Disable the effect of DEL key.

    If you want to disable a Key in KeyDown/KeyPress or KeyUp events, you should use e.Handled = true to let windows know that the key was handled by the window. Like this
    VB Code:
    1. If e.KeyCode = Keys.Delete Then
    2.     e.Handled = True
    3. End If
    Use [code] source code here[/code] tags when you post source code.

    My Articles

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width