...is an event and cannot be called directly. Use a RaiseEvent statement to raise an event

Hi Experts,

I am converting an application that was programmed in C# into VB.  I've got it all translated except for the last form.
There is one line giving me grief.  The two errors that I get relating to the "inmemoryMarkerOverlay.Click += ..." line are:

Public Event Click(sender As Object, e As ThinkGeo.MapSuite.WebEdition.MarkerOverlayClickEventArgs) is an event and cannot be called
directly. Use a RaiseEvent to raise an event.

Delegate 'System.EventHandler(Of ThinkGeo.MapSuite.WebEdition.MarkerOverlayClickEventArgs) requires an 'AddressOf' expression or lambda
expression as the only argument to its constructor.

How can I convert the line below so that it raises the event when the users click event fires?

Thx in advance!
Bob


Private Function InitializeMarkerOverlays(ByVal vehicles As Dictionary(Of String, Vehicle)) As Dictionary(Of String, InMemoryMarkerOverlay)
        Dim markerOverlays As New Dictionary(Of String, InMemoryMarkerOverlay)()

        For Each item As KeyValuePair(Of String, Vehicle) In vehicles

            Dim inmemoryMarkerOverlay As New InMemoryMarkerOverlay()
            inmemoryMarkerOverlay.IsBaseOverlay = False

            inmemoryMarkerOverlay.Click += New EventHandler(Of MarkerOverlayClickEventArgs)(InMemoryMarkerOverlay_Click)

            inmemoryMarkerOverlay.ZoomLevelSet.ZoomLevel01.CustomMarkerStyle = GetCustomMarkerStyle(item.Value.IconPath, item.Value.VehicleName, item.Value.Direction, item.Value)
            inmemoryMarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            markerOverlays.Add(item.Key, inmemoryMarkerOverlay)
            Map1.CustomOverlays.Add(inmemoryMarkerOverlay)
        Next

        Return markerOverlays
    End Function


    Private Sub InMemoryMarkerOverlay_Click(ByVal sender As Object, ByVal args As MarkerOverlayClickEventArgs)
        Map1.Popups.Clear()

        Dim clickedVehicle As Vehicle = (DirectCast(Session("TrackingVehicles"), Dictionary(Of String, Vehicle)))(args.FeatureId)

        Map1.Popups.Add(GetPopup(GetPopupHtmlTemplate(clickedVehicle), clickedVehicle))
    End Sub

Open in new window

LVL 1
sharizodAsked:
Who is Participating?
 
Hawkvalley1Connect With a Mentor Commented:
For clarity sake, this line:
inmemoryMarkerOverlay.Click += New EventHandler(Of MarkerOverlayClickEventArgs)(InMemoryMarkerOverlay_Click)

should be replaced by:
Addhandler inmemoryMarkerOverlay.Click, AddressOf InMemoryMarkerOverlay_Click
0
 
Hawkvalley1Commented:
That's C#'s way of adding an event handler. VB.Net uses the Addhandler statement. Replace that line with this:

Addhandler inmemoryMarkerOverlay.Click, AddressOf InMemoryMarkerOverlay_Click
0
 
sharizodAuthor Commented:
Thanks HawkValley1, but how do I specify the handler is of type MarkerOverlayClickEventArgs in VB as I do in C# ?
0
 
Hawkvalley1Commented:
If it does not recognize the MarkerOverlayClickEventArgs, you may have to full qualify it with ThinkGeo.MapSuite.WebEdition.MarkerOverlayClickEventArgs in the signature of the event.
Or - Imports ThinkGeo.MapSuite.WebEdition .
0
 
sharizodAuthor Commented:
Thanks very much Hawkvalley1!  That fit the bill quite nicely!  Sorry for the delay in finalizing things!

0
All Courses

From novice to tech pro — start learning today.