Clearing all pushpin

Gianmaria
05-04-2005, 11:38 AM
Hi,
how can i remove all pushpins from a map?

regards..

Wilfried
05-04-2005, 12:18 PM
Hi,

MapPoint.DataSets ds = MP.ActiveMap.DataSets;
object o = "My Pushpins";
Recordset rs = MP.ActiveMap.DataSets.get_Item(ref o).QueryAllRecords();
rs.MoveFirst();
while (!rs.EOF) {
rs.Pushpin.Delete();
rs.MoveNext();
}


This is another approach:

object o = "My Pushpins";
try {
MapPoint.DataSet myPushpins = MP.ActiveMap.DataSets.get_Item(ref o);
myPushpins.Delete();
} catch {
// Dataset does not exists
}

Gianmaria
05-05-2005, 03:59 AM
Not works.. sorry...

it say..

The member on the request collection doesent exist.. use a valid name or an index

for each of your example i receive same error.

regards.

Wilfried
05-05-2005, 07:05 AM
Hi,

Strange, I tryed both and both are working. Try following:

object o = 1;

Instead fo the "My Pushpins". I test it and it works also. The first database is the one with the pushpins. Unless of course you have explicitely stored somewhere else (by moving them to another).

I tested it with C# and Mappoint 2004 but should work with other versions also.

cwrude
05-06-2005, 10:31 AM
You can try this:

Dim i as int
Do While oMap.DataSets.Count > 0
i = oMap.DataSets.Count
oMap.DataSets(i).Delete
Loop

 
Web mp2kmag.com
mapforums.com