This example demonstrates how to highlight shapes when mouse cursor is over them and to show the attribute values in the status bar.

using System.Windows.Forms;
using AxMapWinGIS;
using MapWinGIS;
namespace Examples
public partial class MapExamples
// a label to show result in
private ToolStripStatusLabel m_label = null;
// <summary>
// Shows attributes of shape in mouse move event.
// </summary>
public void ShowAttributes(AxMap axMap1, string dataPath, ToolStripStatusLabel label)
axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
string filename = dataPath + "landuse.shp";
Shapefile sf = new Shapefile();
if (sf.Open(filename))
m_layerHandle = axMap1.AddLayer(sf, true);
sf = axMap1.get_Shapefile(m_layerHandle); // in case a copy of shapefile was created by GlobalSettings.ReprojectLayersOnAdding
axMap1.SendMouseMove = true;
axMap1.CursorMode = tkCursorMode.cmIdentify;
axMap1.ShapeHighlighted += AxMap1ShapeHighlighted;
m_label = label;
MessageBox.Show("Failed to open shapefile");
// <summary>
// Handles ShapeHighlighted event and shows attributes of the selected shape in the label
// </summary>
void AxMap1ShapeHighlighted(object sender, _DMapEvents_ShapeHighlightedEvent e)
Shapefile sf = axMap1.get_Shapefile(e.layerHandle);
if (sf != null)
string s = "";
for (int i = 0; i < sf.NumFields; i++)
string val = sf.get_CellValue(i, e.shapeIndex).ToString();
if (val == "") val = "null";
s += sf.Table.Field[i].Name + ":" + val + "; ";
m_label.Text = s;
Available cursor modes. Determines the default respond of map to the action of user.
Definition: Enumerations.cs:344
Commonly used map projections to be set in Form Designer (see AxMap.Projection property).
Definition: Enumerations.cs:1741
Map component for visualization of vector, raster or grid data.
Definition: AxMap.cs:56
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
tkMapProjection Projection
Sets projection of the map. It providers 2 most commonly used coordinate system/projections to be eas...
Definition: AxMap.cs:2709
_DMapEvents_ShapeHighlightedEventHandler ShapeHighlighted
This event is fired when mouse cursor is being moved by user and the cursor enters or leaves neighbor...
Definition: AxMap.cs:3303
tkCursorMode CursorMode
Gets or sets the cursor mode for the map.
Definition: AxMap.cs:456
bool SendMouseMove
Gets or sets whether the map sends mouse move events.
Definition: AxMap.cs:562
int AddLayer(object Object, bool visible)
Adds a layer to the map.
Definition: AxMap.cs:1342
Shapefile get_Shapefile(int layerHandle)
Gets shapefile object associated with the layer.
Definition: AxMap.cs:1546
bool Open(string shapefileName, ICallback cBack)
Opens shapefile from the disk.
Definition: Shapefile.cs:1430
Table Table
Gets the reference to the attribute table associated with the shapefile.
Definition: Shapefile.cs:677
int NumFields
Gets the number of fields in attribute table of the shapefile.
Definition: Shapefile.cs:672
object get_CellValue(int fieldIndex, int shapeIndex)
Gets the value of the specified field for the shape.
Definition: Shapefile.cs:601