First set the ContextMenu property of the TextBox to a dummy, empty ContextMenu instance. This will prevent the default context menu from showing. Then, override the ProcessCmdKey method as follows in a TextBox derived class:
// In C#
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if(keyData == (Keys.Control | Keys.V))
return true;
else
return base.ProcessCmdKey(ref msg, keyData);
}
’ In VB.Net
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
If keyData =(Keys.Control | Keys.V) Then
Return True
Else
Return MyBase.ProcessCmdKey( msg, keyData)
End If
End Function
Share with