View Single Post

  #2 (permalink)  
Old 10-04-2006
masty masty is offline
Junior Member
White Belt
 
Join Date: Sep 2006
Posts: 6
Hi Bule,

To remove all the pushpin you've created you should use the follow code snippet (assuming your map is called "map"):

Code:
foreach (MapPoint.DataSet objDataSet in map.DataSets)
{
if (objDataSet.Name == "My Pushpins")
{
objDataSet.Delete();
}
This because all the Pushpin added by the user ar added in the DataSet "My Pushpins".

Otherwise, if you want to remove only some pushpin you should use something like the follow code snippet:

Code:
foreach (MapPoint.DataSet objDataSet in map.DataSets)
{
if (objDataSet.Name == "My Pushpins")
{
  Recordset rs = objDataSet.QueryAllRecords();
  while (!rs.EOF)
  {
      if (rs.Pushpin.Name.StartsWith("PushPinToDelete1") ||
          rs.Pushpin.Name.StartsWith("PushPinToDelete2"))
      rs.Pushpin.Delete();
      rs.MoveNext();
   }
 }
}
In this example the pushpin named "PushPinToDelete1" and "PushPinToDelete2" will be deleted.
Of course you should use the same pushpin names you used to create them.

Bye!
Reply With Quote