From a posting to the MapPoint newsgroup by Gilles Kohl --

Dear all,

I've made a small utility available that nicely illustrates the power
of .NET 2.0 iterators and (anonymous) delegates. While mainly meant as
a tool for the MapPoint programmer, the demo sample can be useful on
its own - I'm attaching the contents of the README.TXT file also found
in the archive. can be downloaded here:

(or via my MVP profile, as always)

Gilles [MVP].

(Please reply to the group, not via email.
Find my MVP profile with past articles / downloads here:

ForAllPushpins sample application

This archive serves two audiences:

- non-programmers get a useful utility that can
- show or hide the pushpin balloons for all pushpins
of all datasets,
(or only for selected datasets)
- copy their coordinates to the clipboard.

- programmers get a "PushpinIterator" class that has
- a reusable .NET 2.0 style iterator to loop over all pushpins
of all datasets
- methods that call a delegate for all datasets, or all pushpins
of a given dataset
(very handy in combination with anonymous delegates)


If you'd just like to use the sample app as-is, copy the contents of
the "Application" folder to your HD, and launch
(.NET runtime 2.0 required - download from here:

If you already have MapPoint (with some datasets) running,
they will be reflected in the top listbox.

Otherwise, import some pushpins (or add manually) and press the
"Update" button to refresh the list. Select the pushpin set on which
you'd like to do some operation (e.g. "My Pushpins"), and select the
operation you would like to perform (e.g. "Show all balloons"). Click
"Go!" to see it happen.


If you are a developer and would like to see how it is done, extend
the functionality of the app or just reuse the "PushpinIterator"
helper class, the source code is included, just open
ForAllPushpins.sln in the "SourceCode" folder.

Feel welcome to extend the functionality in

The working horse that you can recycle is the PushPinIterator.cs

Here is e.g. how you would iterate over all pushpins in all datasets:

   // create a MapPoint.Application object mpApp, e.g.
   MapPoint.ApplicationClass mpApp = new MapPoint.ApplicationClass();
   // create the iterator object (do this once, after instantiating MapPoint)
   PushpinIterator pushpinIterator = new PushpinIterator(mpApp);
   // loop over all pushpins
   foreach(MapPoint.Pushpin pushpin in pushpinIterator.AllPushpins) 
      // do something with the pushpin here