Question : Disable the right mouse button for pasting into a textbox

I'm using the following code to disable the CTRL-V for pasting into a text box, but the user can still right click the mouse and paste.. I need that option disabled too.

thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Private UndoPast As Boolean = False 
 
Private Sub TextBox1_KeyPress(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If UndoPast Then
            e.Handled = True
            UndoPast = False
        End If
    End Sub
    Private Sub TextBox1_KeyDown(ByVal sender As Object, _
     ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyData = (Keys.Control Or Keys.V) Then
            UndoPast = True
        End If
    End Sub

Answer : Disable the right mouse button for pasting into a textbox

Instead of ContextMenuStrip use ContextMenu,

so, code in form load event should look like,
TextBox1.ContextMenu = New ContextMenu()

In case of any issue, you can find context menu control listed on the toolbar with other controls like label, buttons, etc.
Random Solutions  
 
programming4us programming4us