Select to view content in your preferred language

MapSelectionChangedEvent.Subscribe VB.Net

444
2
Jump to solution
11-06-2023 12:39 PM
EricPfirman
Occasional Contributor

I am using ArcGIS Pro SDK 3.

I have seen multiple examples in C# like this: ...

MapSelectionChangedEvent.Subscribe(OnSelectionChanged);

private void OnSelectionChanged(MapSelectionChangedEventArgs args)

...

 

When I try to implement in VB.Net like this: ...

Dim subscriptionToken = Events.MapSelectionChangedEvent.Subscribe(OnSelectionChanged)

Private Async Sub OnSelectionChanged(ByVal args As Events.MapSelectionChangedEventArgs)

... I get an error that says:

Argument not specified for parameter 'args' of 'Private Sub OnMapSelectionChanged(args As MapSelectionChangedEventArgs)'

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

Subscribe parameter must be Action, not Sub. So, your code should look like that:

Dim eventAction As Action(Of Events.MapSelectionChangedEventArgs) = Sub(arg)
    Dim selection = arg.Selection
    Console.WriteLine("seelection count is {0}", selection.Count)
End Sub

Dim subscriptionToken = Events.MapSelectionChangedEvent.Subscribe(eventAction)

 

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Subscribe parameter must be Action, not Sub. So, your code should look like that:

Dim eventAction As Action(Of Events.MapSelectionChangedEventArgs) = Sub(arg)
    Dim selection = arg.Selection
    Console.WriteLine("seelection count is {0}", selection.Count)
End Sub

Dim subscriptionToken = Events.MapSelectionChangedEvent.Subscribe(eventAction)

 

EricPfirman
Occasional Contributor

Thank you.

0 Kudos