创建鼠标事件参数 [英] create mouse event args

查看:84
本文介绍了创建鼠标事件参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码.在该代码中,我在突出显示的地方遇到了问题.在突出显示的代码'e'中.问题如下

"委托 TreeNodeAdvMouseEventArgs需要表达式或lambda表达式的地址作为其构造函数的唯一参数

"delegate TreeNodeAdvMouseEventArgs requires an address of expression or lambda expression as the only argument to its constructor

我声明了   TreeNodeAdvMouseEventArgs 作为公共委托子TreeNodeAdvMouseEventArgs(ByVal e作为MouseEventArgs)

I declare the  TreeNodeAdvMouseEventArgs  as Public Delegate Sub TreeNodeAdvMouseEventArgs(ByVal e As MouseEventArgs)

我无法解决此问题.请帮助我,并向我解释代码中我做错了什么.

i am not able solve this. please help me and explain me what i did wrong in the code.

Private Function CreateMouseArgs(ByVal e As MouseEventArgs) As TreeNodeAdvMouseEventArgs
            Dim args As New TreeNodeAdvMouseEventArgs(e) With { _
                .ViewLocation = New Point((e.X + Me.OffsetX), ((e.Y + Me._rowLayout.GetRowBounds(Me.FirstVisibleRow).Y) - Me.ColumnHeaderHeight)), _
                .ModifierKeys = Control.ModifierKeys, _
                .Node = Me.GetNodeAt(e.Location) _
            }

            Dim nodeControlInfoAt As NodeControlInfo = Me.GetNodeControlInfoAt(args.Node, e.Location)
            args.ControlBounds = nodeControlInfoAt.Bounds
            args.Control = nodeControlInfoAt.Control
            Return args
        End Function



推荐答案

也许您可以描述为什么需要此代码.编码的目的不是创建最不可维护的代码,而是相反.您的解决方案看起来像是第一个解决方案,也许还有更多可维护的解决方案.

Maybe can you describe why you need this code. The goal of coding is not creating the most not maintainable possible code, but the opposite. Your solution looks like it does the first, maybe there are more maintainable solutions.

VB不是C#,它会在后台自动创建委托.

VB is not C#, it has an automatic creation of delegates behind the scene.


这篇关于创建鼠标事件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆