ToolStripStatusLabel label

https://www.mapwindow.org/documentation/mapwingis4.9/_show_attributes_8cs-example.html

Above link illustrates how to highlight shapes when mouse cursor is over.

public void ShowAttributes([AxMap](https://www.mapwindow.org/documentation/mapwingis4.9/class_ax_map.html) axMap1, string dataPath, ToolStripStatusLabel label)

{

I have to give ToolStripStatusLabel label as parameter in the method. What is the ToolStripStatusLabel label? Is it comes from From design part?
How can I get it?

Hello.

The example just happens to display the results in a ToolStripStatusLabel. But it doesn’t have to be that. It can be a standard Forms.Label, or a TextBox, etc.

1 Like

It shows this error when I run the program…

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

We will need more information, like seeing the code and the line number that had the error.

Thanks.

1 Like
 private void Form1_Load(object sender, EventArgs e)
        {
            ShowAttributes(axMap1, @"C:\Users\User\Downloads\CH_00_D002_20200512\CH_00_D002_20200512.shp");

         
        }



        // <summary>
        // Shows attributes of shape in mouse move event.
        // </summary>
        public void ShowAttributes(AxMap axMap1, string dataPath)
        {
            //axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
            string filename = dataPath;
            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;
            }
            else
            {
                MessageBox.Show("Failed to open shapefile");
            }
        }

// <summary>
        // Handles ShapeHighlighted event and shows attributes of the selected shape in the label
        // </summary>
        public 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;
                Console.WriteLine(s);

            }
        }

When I press the mouse left button o the map, it shows this error above: