This project is read-only.

Selection does not refresh after entering legend properties dialogue

May 9, 2012 at 4:33 PM
Edited May 9, 2012 at 5:47 PM


In my application I am using dotspatial libraries with map and legend controls, I am encountering an error in my application after a user changes a layers properties by right clicking in the legend and entering the properties dialogue.  After the user has entered the layer properties the selection is no longer shown on the map and the previous selection still appears to be selected. I know there is a selection still being made since I am capturing the layers selection changed event and populating a datagridview with the attribute results.

In addition to the map no longer refreshing the selection after I open the layer properties window I am no longer able to use the IFeatureLayer.selectbyattributes, it will now always return 0 results.

Is there anything that i could do differently so the user can see the selection after entering the properties windows? or any other recommendations for this issue?

Any advice would be appreciated.

Thank You,





May 9, 2012 at 8:54 PM

Does this problem also occur in demomap or MapWindow 6?

May 10, 2012 at 9:44 PM

I could not replicate this issue with demomap or mapwindow 6. I must be missing something.

Would this have something to do with how I have the project configured or settings in the dotspatial controls (Legend and Map) or the App Manager?

I reviewed the demo map controls properites and everything looks to be the same. 


Jun 5, 2012 at 1:35 PM


I just wanted to follow up on this issue since it is still occuring, it turns out when I add a layer programmatically then enter the legend properties it encouters the issues described above as well as recieving an "object reference not set to an instance of an object" error if attempting to open anything from the detailed properties windows.  There is also an error when trying to reopen a *.dspx that has been saved with a layer created programmatically.

The code below shows how i am creating and adding the layer, I am reading the infromation infrom an sql query, the layer adds to the map without any issues and looks fine . I think i am just missing something that needs to be set in order for the legend properties and dspx  to recognize this layer properly.

            pointF = New FeatureSet(FeatureType.Point)
            pointF.Name = "Temp"
            pointF.Filename = "C:\Temp\Temp.shp"

            pointF.Projection = DotSpatial.Projections.ProjectionInfo.FromEsriString("PROJCS[""WGS_1984_UTM_Zone_19S"",GEOGCS[""GCS_WGS_1984"",DATUM[""D_WGS_1984"",SPHEROID[""WGS_1984"",6378137.0,298.257223563]],PRIMEM[""Greenwich"",0.0],UNIT[""Degree"",0.0174532925199433]],PROJECTION[""Transverse_Mercator""],PARAMETER[""False_Easting"",500000.0],PARAMETER[""False_Northing"",10000000.0],PARAMETER[""Central_Meridian"",-69.0],PARAMETER[""Scale_Factor"",0.9996],PARAMETER[""Latitude_Of_Origin"",0.0],UNIT[""Meter"",1.0],AUTHORITY[""EPSG"",32719]]")

            'initialize the featureSet attribute table
            Dim colID As New DataColumn("PointID")
            colID.DataType = System.Type.GetType("System.Int32")

            For i = 0 To dr.FieldCount - 1
                Dim Col As New DataColumn(dr.GetName(i))
                Col.DataType = dr.GetFieldType(i)
            Next i

        While dr.Read

                Dim coord As New Coordinate
                Dim dNorth As Double
                Dim dEast As Double

                coord.X = CDbl(dr("X"))
               dEast = CDbl(dr("X"))

                        coord.Y = CDbl(dr("Y").ToString)
                        dNorth = CDbl(dr("Y").ToString)

                pointID = pointID + 1

                Dim currentFeature As IFeature
                'Create a new point
                'Input parameter is clicked point coordinate
                Dim point As New Global.DotSpatial.Topology.Point(coord)
                'Add the point into the Point Feature
                'assigning the point feature to IFeature because via it only we can set the attributes.
                currentFeature = pointF.AddFeature(point)
                'increase the point id
                currentFeature.DataRow("PointID") = pointID

                'set the ID attribute

                For i = 0 To dr.FieldCount - 1
                    If Not IsNothing(dr(dr.GetName(i))) Then
                        If Not IsDBNull(dr(dr.GetName(i))) Then
                            Select Case dr.GetFieldType(i)
                                Case System.Type.GetType("System.String")
                                    currentFeature.DataRow(dr.GetName(i)) = dr(dr.GetName(i)).ToString
                                Case System.Type.GetType("System.Date")
                                    currentFeature.DataRow(dr.GetName(i)) = CDate(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.Double")
                                    currentFeature.DataRow(dr.GetName(i)) = CDbl(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.Int32")
                                    currentFeature.DataRow(dr.GetName(i)) = CInt(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.Int16")
                                    currentFeature.DataRow(dr.GetName(i)) = CInt(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.Decimal")
                                    currentFeature.DataRow(dr.GetName(i)) = CDec(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.Single")
                                    '       Case System.Type.gettype
                                    currentFeature.DataRow(dr.GetName(i)) = CInt(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.Numeric")
                                    currentFeature.DataRow(dr.GetName(i)) = CDbl(dr(dr.GetName(i)))
                                Case System.Type.GetType("System.DateTime")
                                    currentFeature.DataRow(dr.GetName(i)) = CDate(dr(dr.GetName(i)))
                                Case Else
                                    MsgBox("Add support for datatype: " & dr.GetDataTypeName(i))
                            End Select
                        End If

                    End If

                Next i

            End If

            '      Catch ex As Exception

            '   End Try

        End While



            Dim pointLayer As MapPointLayer = CType(uxmap.MapFrame.Layers.Add(pointF), MapPointLayer)
            pflayer = pointLayer
            AddHandler pointLayer.SelectionChanged, AddressOf Layer_SelectionChanged
            AddHandler pointLayer.RemoveItem, AddressOf Layer_Removed

            'Create a new symbolizer
            Dim symbol As New PointSymbolizer(Color.Black, Global.DotSpatial.Symbology.PointShape.Ellipse, 6)
            'Set the symbolizer to the point layer
            pointLayer.Symbolizer = symbol
            'Set the legentText as point
            pointLayer.LegendText = "NEW LAYER"
            uxmap.ViewExtents = pointF.Extent

        Catch ex As Exception
        End Try

Any help would be appreciated

Thanks your,







Oct 28, 2012 at 8:02 PM
Edited Oct 28, 2012 at 8:03 PM

you must add the following lines after pointF.Save()


pointF.InvalidateVertices() 'allows refreshing the map