Hi,

I am developing a windows application, In that i use richtextbox control in that i allow only character. when i copy number and paste in richtext box it takes number, but when i type a number it work properly and shows error message. so please give me answer.

Two steps to be followed to disable the Copy-Paste feature in a textbox,

1) To stop right click copy/paste, disable the default menu and associate the textbox with an empty context menu that has no menu items.

2) To stop the shortcut keys you'll need to override the ProcessCmdKey method:

private const Keys CopyKey = Keys.Control | Keys.C;
private const Keys PasteKey = Keys.Control | Keys.V;

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { 
    if((keyData == CopyKey) || (keyData == PasteKey)){
        return true;
    } else {
        return base.ProcessCmdKey(ref msg, keyData);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.