qq_39817386
qq_39817386
采纳率0%
2017-08-11 13:40

求教VB.NET关于自己写的控件添加鼠标事件问题11

自己引用了一个地图控件Gmap,由于其未添加marker的点击事件,所以需要自己写鼠标事件

新建一个GGmarker类继承于地图控件的GmarkerGoogle

public class GGmarker :inherits GmarkerGoogle

???

end class

在Form_Load里面实例化

marker = new GGmarker()

public sub marker_Click() handles marker.Click

msgBox()

end sub

然后marker就可以在地图上显示出一个标记

但是想点击标记的时候能够响应鼠标事件,弹出一个msgbox

请问下怎么写鼠标响应事件呢?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • qq_39817386 qq_39817386 4年前

    Class1
    Public Class Class1 : Inherits GMarkerGoogle

    Public Event Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Public Sub New(ByVal p As GMap.NET.PointLatLng, ByVal type As GMap.NET.WindowsForms.Markers.GMarkerGoogleType)
        MyBase.New(p, type)
    End Sub
    Public Sub onMarkerClick(ByVal sender As Object, ByVal e As System.EventArgs)
        RaiseEvent Click(sender, e)
    End Sub
    

    End Class

    在form1里面的代码:
    Public Class Form1

    Public WithEvents cqqk As Class1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load     
        cqqk = New Class1(New PointLatLng(29.5161103860623, 106.929931640625), GMarkerGoogleType.green)
    End Sub
    Private Sub cqqk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cqqk.Click
        MsgBox("调用了marker的鼠标点击事件", MsgBoxStyle.YesNo, "a")
    End Sub
    

    End Class

    点赞 评论 复制链接分享
  • caozhy 从今以后生命中的每一秒都属于我爱的人 4年前
    点赞 评论 复制链接分享

相关推荐