在winform中,如果form上或者是控件上有一个combobox控件,当你选择这个控件,当你鼠标移动其他地方,滑动鼠标时,这时combobox的选择值就会随之鼠标一起变化,如果你不想让comboBox的值发生变化,其实你可以禁掉鼠标滑动的事件!

 第一步:例如建了一个form1的表单,一定要让form1表单继承IMessageFilter这个

            Form1: Form,IMessageFilter

第二步:在form1上初始化发送消息的事件

           Application.AddMessageFilter(this);

第三步:添加捕捉消息的事件:

        public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg == 522)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
相关资源
相似解决方案