Solved

unable paste in textbox

Posted on 2006-07-23
2
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Assisted Solution

by:DrAske
DrAske earned 100 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 150 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

Independent Software Vendors: 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

624 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