Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 3 of 3

How to add click event for VB.Net ?

This is a discussion on How to add click event for VB.Net ? within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello... We are have a vb.net app and are able to display a map with pushpins that represent the results ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    How to add click event for VB.Net ?

    Hello...

    We are have a vb.net app and are able to display a map with pushpins that represent the results from a sql server database query. This works fine. Now....I need to be able to let the user double-click on one of the pushpins and then display a modal dialog that contains some detailed info about the pushpin location. Is this possible? I saw some articles and posts that mention the SelectedChange event....but I am having problems getting this to work. If anyone knows of a good sample or article that would be appreciated.

    Thank you

  2. #2
    mrobold is offline Junior Member White Belt
    Join Date
    Nov 2003
    Posts
    7
    Well, if you're looking to trap what they've selected, you can use the selection changed event like so:

    Code:
    Private Sub MapCtrl_SelectionChange(ByVal sender As Object, ByVal e As AxMapPoint._IMappointCtrlEvents_SelectionChangeEvent) Handles MapCtrl.SelectionChange
    
            If TypeOf (e.pNewSelection) Is MapPoint.Pushpin Then
    
                ' A pushpin has been selected, get a reference to it
                 Dim pin As MapPoint.Pushpin = e.pNewSelection
    
                 ' Call your method to display the box
                 Me.DisplayPinDetails(pin)
    
            End If
    
        End Sub
    Of course, this will happen on a single-click instead of a double-click. Your other option would probably be to trap the BeforeDoubleClick event, determine the appropriate pushpin, and then run the same detail method.

    E.G.

    Code:
    Private Sub MapCtrl_DblClick(ByVal sender As Object, ByVal e As AxMapPoint._IMappointCtrlEvents_BeforeDblClickEvent) Handles MapCtrl.DoublClick
            Dim searchResults As MapPoint.FindResults = Me.ActiveMap.ObjectsFromPoint(e.x, e.y)
            Dim pin As MapPoint.Pushpin
            For Each result As Object In searchResults
                If TypeOf result Is MapPoint.Pushpin Then
                    pin = result
                    Exit For
                End If
            Next
    
            ' Call your method to display the box
             Me.DisplayPinDetails(pin)
    End Sub
    Of course, the above code assumes you've only got one pushpin at the selection point. If you want to plan for many pushpins, you'll have to present the user with a list of those to make a selection.

    BEWARE: This may cause your app to hang if your "DisplayPinDetails" method takes too long to run (I'm having problems along that line due to OleServer timeouts).

    Hope this helps.

    MR

  3. #3
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    Thank you very much. I was having many problems trying to figure out how to refer to the object and determine a pushpin selection.

    Thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Right-Click event on the colored countries
    By bgopal in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-14-2005, 10:42 AM
  2. Where did I click on that line?
    By Jumbly in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 12-08-2004, 04:53 AM
  3. Long/Lat from click.
    By Milo in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 10-29-2004, 08:32 AM
  4. Disable Click Event property in a rendered map/mapimage ?
    By the_jock in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-28-2004, 06:17 AM
  5. Double Click on map
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 08-08-2003, 07:42 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25