Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

unable paste in textbox

Posted on 2006-07-23
2
Medium Priority
?
451 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 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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