zoukankan      html  css  js  c++  java
  • 【DevExpress】老版TreeList和GridControl 中控件 MouseWheel事件禁用解决方法

    期望目标:TreeList和GridControl中禁用鼠标MouseWheel事件对控件值的更改。

    处理思路:在TreeList_ShownEditor事件中,增加对ActiveEditor的MouseWheel事件处理,禁用掉即可。

    遇到问题:老版DevExpress中对ActiveEditor.MouseWheel的Handle=true无效。

                  参加官方问题地址 http://www.devexpress.com/Support/Center/Question/Details/Q148215

    解决方法:

        既然无法禁用值的改变,那就从改变后恢复着手。代码如下:

        Private activeEditor As DevExpress.XtraEditors.BaseEdit = Nothing       '当前编辑控件
        Private isMouseWheelChanged As Boolean = False                          '是否为鼠标滚轮滚动改变
        Private oActiveEditorOldValue As Object = Nothing                       '初始值
    
        Private Sub TreeList_ShownEditor(ByVal sender As System.Object, ByVal e As System.EventArgs)
            activeEditor = m_tree.ActiveEditor
            oActiveEditorOldValue = activeEditor.EditValue
            AddHandler activeEditor.MouseWheel, AddressOf ActiveEditor_MouseWheel
            AddHandler activeEditor.EditValueChanging, AddressOf ActiveEditor_EditValueChanging
        End Sub
    Private Sub TreeList_HiddenEditor(ByVal sender As Object, ByVal e As System.EventArgs) If activeEditor IsNot Nothing Then isMouseWheelChanged = False oActiveEditorOldValue = Nothing End If End Sub
    ’出自 http://caryliu.cnblogs.com Private Sub ActiveEditor_MouseWheel(ByVal sender As System.Object, ByVal e As MouseEventArgs) isMouseWheelChanged = True If oActiveEditorOldValue IsNot Nothing Then Try RemoveHandler activeEditor.EditValueChanging, AddressOf ActiveEditor_EditValueChanging activeEditor.EditValue = oActiveEditorOldValue Catch ex As Exception Finally AddHandler activeEditor.EditValueChanging, AddressOf ActiveEditor_EditValueChanging End Try End If '转化为列表滚动 Dim scrollLines As Integer = SystemInformation.MouseWheelScrollLines If (scrollLines = -1) Then scrollLines = m_tree.ViewInfo.VisibleRowCount m_tree.TopVisibleNodeIndex += IIf(e.Delta > 0, -scrollLines, scrollLines) End Sub

    Private Sub ActiveEditor_EditValueChanging(ByVal sender As System.Object, ByVal e As DevExpress.XtraEditors.Controls.ChangingEventArgs) If isMouseWheelChanged Then e.Cancel = True Exit Sub End If oActiveEditorOldValue = e.OldValue End Sub
    作者:Cary Liu


    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,
    且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    通信编程:WSAEventSelect 模型通信
    VMware 安装 Red Hat 6 虚拟机
    通信编程:Select 模型通信
    Android:隐式 Intent 调用标准 Action
    Android:显式 Intent
    Linux(CentOS)用户修改密码有效期
    linux 系统中断信息
    qt udp 聊天
    docker更改镜像存储位置
    通过dockerfile构建singularity镜像
  • 原文地址:https://www.cnblogs.com/caryliu/p/2935373.html
Copyright © 2011-2022 走看看