private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.V)
            {
                   MessageBox.Show("111");
                   e.Handled = true;
                
            }
        }//为什么在textbox里就屏蔽不了ctrl+v                private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.V)
            {
                MessageBox.Show("111");
                e.Handled = true;            }
        }为什么在richTextBox里就可以评比呢。奇怪。郁闷。同样的代码~~为什么呢。还有是说有什么其他的原因??

解决方案 »

  1.   

    这个我是用自定义控件的方法,实现的防拷贝textbox。写一个控件继承于textbox。然后加上
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
            {            if (keyData == (Keys.Control | Keys.C) || keyData == (Keys.Control | Keys.V))
                {
                    MessageBox.Show("不能粘贴,复制");
                    return true;
                }            else
                    return base.ProcessCmdKey(ref msg, keyData);
                //            return false;        }
      

  2.   

    LZ,,,,,,你试试用KEYUP事件。。在key_up事件中是好用的 if (e.Control && (e.KeyCode == Keys.C))
                {
                    this.textBox1.Text = "c";
                }