Community of VE/MapPoint Users and Developers
This is a discussion on Selecting a Shape by Name in C# within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; According to the documentation, I should be able to find a shape by its name using the Shapes collection's Item ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Selecting a Shape by Name in C# I've done this in the past with VB6, but it crashes with C#. Has anyone managed to find a shape without iterating through the entire collection? (I see in another thread, Wilfried iterates through the collection looking for a matching name). Eg. something like: MapPoint.Shape myShape = myMap.Shapes.Item("fred"); Perhaps I'm seeing a variant / string problem? Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
| Re: Selecting a Shape by Name in C#
Hi Richard, Almost, but it is get_Item and it has to be a ref to the name like this: Code: object o = theNameToFind; Shape s = MP.ActiveMap.Shapes.get_Item(ref o);
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| ||||
| Re: Selecting a Shape by Name in C#
Wilfried, That's what I had originally - but it started to throw an exception! Is a normal C# string okay, or does it have to be cast as something else? (I'm thinking of the dozen or so different string types found on Windows C++!) Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
| Re: Selecting a Shape by Name in C#
Hi Richard, Normal string. I just tryed this in a test project and it works. I paste it here: Code: Shape s = MP.ActiveMap.Shapes.AddShape(GeoAutoShapeType.geoShapeRadius, loc, dia, dia); s.Name = "wilfried"; object o = s.Name; s = MP.ActiveMap.Shapes.get_Item(ref o); Console.WriteLine(s.Name);
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| ||||
| Re: Selecting a Shape by Name in C#
Hmmm.... I'll have another look at my code tomorrow. Thanks Wilfried - although the above code doesn't rule out the possibility that the text is a "non-conventional" string - you copy from the name property into the object that you use as the parameter. Richard
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools Pre-Order MapPoint 2009 today: http://www.mapping-tools.com/mappoint2009 |
| |||
| Re: Selecting a Shape by Name in C#
Hi Richard, This is true. It is a conventional string, but there can be a big difference between this: Code: string name = "wilfried"; object o = name; s = MP.ActiveMap.Shapes.get_Item(ref o); Code: object o = "wilfried"; s = MP.ActiveMap.Shapes.get_Item(ref o);
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| ||||
| Posted By | For | Type | Date | |
| Lat/Long in MapPoint 2002 - MapPoint Articles - MP2K Magazine | This thread | Refback | 04-27-2007 04:43 AM | |
| Microsoft MapPoint 2006 - MP2K Magazine | This thread | Refback | 04-17-2007 01:59 PM | |
| MapPoint Gets New General Manager - MapPoint News - MP2K Magazine | This thread | Refback | 04-14-2007 08:54 AM | |
| Determing Whether A Point Is Located Inside Polygon - MapPoint Articles - MP2K Magazine | This thread | Refback | 04-11-2007 10:26 PM | |
| Programming MapPoint in .NET - MP2K Magazine | This thread | Refback | 04-11-2007 10:10 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does an object reside in my Shape or Shape boundaries? | hotrdd | MapPoint 2006/2009 Discussion | 1 | 08-04-2005 09:51 PM |
| Selecting cities in drivetime | Anonymous | MapPoint 2006/2009 Discussion | 5 | 02-02-2005 04:21 PM |
| Selecting Shape Based on Name | Anonymous | MapPoint 2006/2009 Discussion | 1 | 09-07-2004 10:01 AM |
| Selecting a prviously drawn shape | CSG | MapPoint 2006/2009 Discussion | 1 | 03-24-2004 10:08 AM |
| Selecting pushpins within a shape | Anonymous | MapPoint 2006/2009 Discussion | 1 | 09-26-2002 08:11 AM |
Flight Times
At Holiday Hypermarket not only can you book some great value flights but we have links to help you check flight times for arrivals and departures from each airport.
Flights to Turkey
Find and book flights to Turkey. Travel Counsellors can help with travel to Turkey including flights and accommodation.
Holidays to Thailand
The best cultures and backgrounds make Thailand an interesting and memorable country to visit. Book great value holidays to Thailand online at dealchecker.co.uk.
Barbados Holidays
Barbados holidays can be a wonderful break from the rat race or an exciting, action packed adventure. Plan the perfect holiday in Barbados.
Holidays
For bargain holidays to destinations including Mexico, South Africa, India and more, visit ULookUBook online today. Check out our free travel guides to help you make an informed decision for your holidays.
Price Comparison
Price comparison is the name of the game at Travel.co.uk. Visit our website and see for yourself.
Holidays to Goa
Golden beaches, coconut trees. Visit On The Beach for holidays to Goa, and experience India!