Solved

unable paste in textbox

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now