屏蔽TextBox控件上的粘贴功能

实现效果:

  

知识运用:

  TextBox类的WndProc方法

实现代码:

    class TextBox1 : TextBox {
        public const int WM_Paset = 0x0302;                 //粘贴消息信息  
        protected override void WndProc(ref Message m)      //重写消息处理方法
        {
            if (m.Msg != WM_Paset)                          //屏蔽粘贴消息信息
            {
                base.WndProc(ref m);                        //调用基类消息处理方法
            }
        }
    }
原文地址:https://www.cnblogs.com/feiyucha/p/10145778.html