Solved

unable paste in textbox

Posted on 2006-07-23
2
440 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

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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

738 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