Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

unable paste in textbox

Posted on 2006-07-23
2
Medium Priority
?
458 Views
Last Modified: 2010-04-16
hi there ,
i have an numeric textbox
but if i copy some text an enter the textbox an make paste on it
the text is performd in the texbox

how i can  unable the paste to the textbox ?


thanks ....
0
Comment
Question by:Tech_Men
2 Comments
 
LVL 9

Assisted Solution

by:DrAske
DrAske earned 400 total points
ID: 17163365
Use Mouse Down Event, Then Clear the Clipboard ..

private void TxtBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
    Clipboard.SetDataObject("");
}

Try It ..

regards,Ahmad;
0
 
LVL 10

Accepted Solution

by:
smegghead earned 600 total points
ID: 17163373
The first thing to do is to set the ContextMenu propert of the textbox equal to a new empty 'ContextMenu', then you can either disable the paste keys in the whole form, or on the individual control.

protected override bool ProcessCmdKey(ref Message msg,Keys keyData)
{
      if (keyData==(Keys.Control|Keys.V) || keyData==(Keys.Shift|Keys.Insert))
            return true;
      else
            return base.ProcessCmdKey(ref msg,keyData);
}

If you choose to do it for the whole form, then it's just a matter of adding the above code to the form class. If you want to it to just apply to a sinlge control, you have to create a new control which inherits from TextBox, and include the above code in the overridden class.

Hope this helps
Smg.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question