Subscribe to Subscribers
Talk to Webmaster Tony John

Resources » Code Snippets » C# Syntax

How to disable right click and cut/copy and paste options in user controls.


Posted Date:     Category: C# Syntax    
Author: Member Level: Bronze    Points: 7


In this article,I will explain how to disable right click and cut/copy and paste options in user controls like text box ,rich text boxes etc in applications.This may be useful while developing security rich applications.



 


In this article,I have described how to disable right click and cut/copy and paste options in user controls.These may be used in applications which need more security while getting information from the user like password,PIN number etc.This would help us to double check whether the user has given the correct data.

1. The code given below describes how to diable right click option.
The code has to used in textbox mouse down event.



private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
MessageBox.Show("Right click is disabled");
}
}



2.The code given below describes how to disable cut/copy and paste options( Ctrl+X,Ctrl+C and Ctrl+V) through keys.
The code has to be used in textbox keydown event.



private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control == true)
{
MessageBox.Show("Cut/Copy and Paste Options are disabled");
}
}






Did you like this resource? Share it with your friends and show your love!


Responses to "How to disable right click and cut/copy and paste options in user controls."

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Relational operators in C#
    Previous Resource: Show an animated loading GIF image on a Windows Form (c#)
    Return to Resources
    Post New Resource
    Category: C# Syntax


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Disable right click  .  Disable cut  .  Copy and paste options  .  Textbox right click disable  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.